scripts: extract_dts_includes: use deepcopcy when accessing reduced

Variables 'names' is copying value from 'reduced' dict and gives
illusion that any computation could be done on copied data.
Problem is that later computation on 'names' will modify data in
'reduced'.
Use deepcopy in order to avoid erasing thing in reduced.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
Erwan Gouriou 2018-07-02 14:39:07 +02:00 committed by Kumar Gala
commit 69a211fe00

View file

@ -15,6 +15,7 @@ import re
import yaml
import argparse
import collections
from copy import deepcopy
from devicetree import parse_file
from extract.globals import *
@ -439,12 +440,17 @@ def extract_node_include_info(reduced, root_node_address, sub_node_address,
if re.match(k + '$', c):
if 'pinctrl-' in c:
names = node['props'].get('pinctrl-names', [])
names = deepcopy(node['props'].get(
'pinctrl-names', []))
else:
names = node['props'].get(c[:-1] + '-names', [])
if not names:
names = node['props'].get(c + '-names', [])
if not c.endswith("-names"):
names = deepcopy(node['props'].get(
c[:-1] + '-names', []))
if not names:
names = deepcopy(node['props'].get(
c + '-names', []))
else:
names = []
if not isinstance(names, list):
names = [names]