mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
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>
This commit is contained in:
parent
9102211855
commit
69bed6c241
3 changed files with 12 additions and 7 deletions
5
dtc.h
5
dtc.h
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue