Skip to content

Commit

Permalink
dtb: Handle multiple types differing in sign
Browse files Browse the repository at this point in the history
If a property has multiple types differing in sign, drop the unsigned
type. This prevents us from falling back to a 'uint32-array' which is
now decoded differently.

Same thing could happen for arrays or matrices, but ignore those for
now.

Signed-off-by: Rob Herring (Arm) <[email protected]>
  • Loading branch information
robherring committed Jul 31, 2024
1 parent c00f747 commit f13c181
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dtschema/dtb.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ def prop_value(validator, nodename, p):
if prop_types >= {'phandle', 'phandle-array'}:
prop_types -= {'phandle'}

# Drop the unsigned type if both signed and unsigned type exists
if prop_types >= {'int64', 'uint64'}:
prop_types -= {'uint64'}
if prop_types >= {'int32', 'uint32'}:
prop_types -= {'uint32'}
if prop_types >= {'int16', 'uint16'}:
prop_types -= {'uint16'}
if prop_types >= {'int8', 'uint8'}:
prop_types -= {'uint8'}

if len(prop_types) > 1:
if {'string', 'string-array'} & prop_types:
str = bytes_to_string(data)
Expand Down

0 comments on commit f13c181

Please sign in to comment.