diff options
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 |
commit | 69bed6c2418f484561263aadbb886ffb925e6b38 (patch) | |
tree | 325e2bb51f677e1ab5b218df5684b32b694dbac8 /dtc.h | |
parent | 910221185560fe0c5dc0997dd7d3b472a0a7cdea (diff) | |
download | device-tree-compiler-69bed6c2418f484561263aadbb886ffb925e6b38.tar.gz |
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 'dtc.h')
-rw-r--r-- | dtc.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -51,6 +51,11 @@ extern int annotate; /* annotate .dts with input source location */ typedef uint32_t cell_t; +static inline bool phandle_is_valid(cell_t phandle) +{ + return phandle != 0 && phandle != ~0U; +} + static inline uint16_t dtb_ld16(const void *p) { const uint8_t *bp = (const uint8_t *)p; |