summaryrefslogtreecommitdiff
path: root/livetree.c
diff options
context:
space:
mode:
author Andre Przywara <andre.przywara@arm.com> 2021-06-18 18:20:28 +0100
committer David Gibson <david@gibson.dropbear.id.au> 2021-06-21 15:28:21 +1000
commit69bed6c2418f484561263aadbb886ffb925e6b38 (patch)
tree325e2bb51f677e1ab5b218df5684b32b694dbac8 /livetree.c
parent910221185560fe0c5dc0997dd7d3b472a0a7cdea (diff)
dtc: Wrap phandle validity check
In several places we check for a returned phandle value to be valid, for that it must not be 0 or "-1". Wrap this check in a static inline function in dtc.h, and use ~0U instead of -1 on the way, to keep everything in the unsigned realm. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20210618172030.9684-4-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'livetree.c')
-rw-r--r--livetree.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/livetree.c b/livetree.c
index dfbae65..cc61237 100644
--- a/livetree.c
+++ b/livetree.c
@@ -559,7 +559,7 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
{
struct node *child, *node;
- if ((phandle == 0) || (phandle == -1)) {
+ if (!phandle_is_valid(phandle)) {
assert(generate_fixups);
return NULL;
}
@@ -594,7 +594,7 @@ cell_t get_node_phandle(struct node *root, struct node *node)
static cell_t phandle = 1; /* FIXME: ick, static local */
struct data d = empty_data;
- if ((node->phandle != 0) && (node->phandle != -1))
+ if (phandle_is_valid(node->phandle))
return node->phandle;
while (get_node_by_phandle(root, phandle))