summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-07-29 04:23:09 +0300
committerSimon Glass <sjg@chromium.org>2021-08-01 18:05:24 +0300
commitdf82de805172687e88dd7d72b68a9223b0a4c269 (patch)
treea65bf0176ce443dd5df49581da5cd69b7d4e2464 /tools
parentcb8970092f2cd5f1eaadf7d15d28cb905067e07f (diff)
downloadu-boot-df82de805172687e88dd7d72b68a9223b0a4c269.tar.xz
dtoc: Rename is_wider_than() to reduce confusion
The current name is confusing because the logic is actually backwards from what you might expect. Rename it to needs_widening() and update the comments. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/dtoc/fdt.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 3996971e39..9749966d5f 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -24,16 +24,19 @@ from patman import tools
# A list of types we support
class Type(IntEnum):
+ # Types in order from widest to narrowest
(BYTE, INT, STRING, BOOL, INT64) = range(5)
- def is_wider_than(self, other):
- """Check if another type is 'wider' than this one
+ def needs_widening(self, other):
+ """Check if this type needs widening to hold a value from another type
- A wider type is one that holds more information than an earlier one,
- similar to the concept of type-widening in C.
+ A wider type is one that can hold a wider array of information than
+ another one, or is less restrictive, so it can hold the information of
+ another type as well as its own. This is similar to the concept of
+ type-widening in C.
This uses a simple arithmetic comparison, since type values are in order
- from narrowest (BYTE) to widest (INT64).
+ from widest (BYTE) to narrowest (INT64).
Args:
other: Other type to compare against
@@ -149,7 +152,7 @@ class Prop:
update the current property to be like the second, since it is less
specific.
"""
- if self.type.is_wider_than(newprop.type):
+ if self.type.needs_widening(newprop.type):
if self.type == Type.INT and newprop.type == Type.BYTE:
if type(self.value) == list:
new_value = []