From ca04494d76bf1152cd9ab1f67af5101c86e0824f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 28 Jul 2021 19:23:10 -0600 Subject: dtoc: Fix widening an int array to an int An int array can hold a single int so we should not need to do anything in the widening operation. However due to a quirk in the code, an int[3] widened with an int produced an int[4]. Fix this and add a test. Fix a comment typo while we are here. Signed-off-by: Simon Glass Reported-by: Tom Rini --- tools/dtoc/fdt.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tools/dtoc/fdt.py') diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 9749966d5fb..429e95f9a96 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -163,13 +163,14 @@ class Prop: self.value = new_value self.type = newprop.type - if type(newprop.value) == list and type(self.value) != list: - self.value = [self.value] - - if type(self.value) == list and len(newprop.value) > len(self.value): - val = self.GetEmpty(self.type) - while len(self.value) < len(newprop.value): - self.value.append(val) + if type(newprop.value) == list: + if type(self.value) != list: + self.value = [self.value] + + if len(newprop.value) > len(self.value): + val = self.GetEmpty(self.type) + while len(self.value) < len(newprop.value): + self.value.append(val) @classmethod def GetEmpty(self, type): -- cgit v1.2.3