1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-27 13:31:16 +02:00

dtoc: Tidy up implementation of AddStringList()

Refactor this to avoid a loop. Also add a test for an empty string.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
This commit is contained in:
Simon Glass
2022-03-05 20:18:56 -07:00
parent b13114cd21
commit 0ded4d434d
3 changed files with 13 additions and 3 deletions

View File

@@ -158,6 +158,8 @@ def GetString(node, propname, default=None):
if not prop:
return default
value = prop.value
if not prop.bytes:
return ''
if isinstance(value, list):
raise ValueError("Node '%s' property '%s' has list value: expecting "
"a single string" % (node.name, propname))
@@ -179,6 +181,8 @@ def GetStringList(node, propname, default=None):
if not prop:
return default
value = prop.value
if not prop.bytes:
return []
if not isinstance(value, list):
strval = GetString(node, propname)
return [strval]