[rtems commit] libfdt: libfdt_wip: Fix comparison warning

Sebastian Huber sebh at rtems.org
Thu Dec 16 13:58:33 UTC 2021


Module:    rtems
Branch:    master
Commit:    58b4fe7cd59b7a31994bcd441fa9497ebb7d79bc
Changeset: http://git.rtems.org/rtems/commit/?id=58b4fe7cd59b7a31994bcd441fa9497ebb7d79bc

Author:    Andre Przywara <andre.przywara at arm.com>
Date:      Thu Oct  1 17:46:28 2020 +0100

libfdt: libfdt_wip: Fix comparison warning

With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in fdt_setprop_inplace_namelen_partial().

fdt_getprop_namelen() will only return negative error values in "proplen"
if the return value is NULL. So we can rely on "proplen" being positive
in our case and can safely cast it to an unsigned type.

Signed-off-by: Andre Przywara <andre.przywara at arm.com>
Message-Id: <20201001164630.4980-5-andre.przywara at arm.com>
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>

---

 cpukit/dtc/libfdt/fdt_wip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/dtc/libfdt/fdt_wip.c b/cpukit/dtc/libfdt/fdt_wip.c
index f64139e..c2d7566 100644
--- a/cpukit/dtc/libfdt/fdt_wip.c
+++ b/cpukit/dtc/libfdt/fdt_wip.c
@@ -23,7 +23,7 @@ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
 	if (!propval)
 		return proplen;
 
-	if (proplen < (len + idx))
+	if ((unsigned)proplen < (len + idx))
 		return -FDT_ERR_NOSPACE;
 
 	memcpy((char *)propval + idx, val, len);



More information about the vc mailing list