[rtems commit] libfdt: fdt_get_string(): Fix comparison warnings
Sebastian Huber
sebh at rtems.org
Thu Dec 16 13:58:33 UTC 2021
Module: rtems
Branch: master
Commit: 3437b91356d088c7da45ed49a3e76846eecc9152
Changeset: http://git.rtems.org/rtems/commit/?id=3437b91356d088c7da45ed49a3e76846eecc9152
Author: Simon Glass <sjg at chromium.org>
Date: Mon Sep 21 17:52:55 2020 +0100
libfdt: fdt_get_string(): Fix comparison warnings
With -Wsign-compare, compilers warn about a mismatching signedness in
comparisons in fdt_get_string().
In the first two cases, we have just established that the signed values
are not negative, so it's safe to cast the values to an unsigned type.
Signed-off-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Andre Przywara <andre.przywara at arm.com>
Message-Id: <20200921165303.9115-7-andre.przywara at arm.com>
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
cpukit/dtc/libfdt/fdt_ro.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cpukit/dtc/libfdt/fdt_ro.c b/cpukit/dtc/libfdt/fdt_ro.c
index 3c8d143..ddb5a2d 100644
--- a/cpukit/dtc/libfdt/fdt_ro.c
+++ b/cpukit/dtc/libfdt/fdt_ro.c
@@ -53,7 +53,7 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp)
err = -FDT_ERR_BADOFFSET;
absoffset = stroffset + fdt_off_dt_strings(fdt);
- if (absoffset >= totalsize)
+ if (absoffset >= (unsigned)totalsize)
goto fail;
len = totalsize - absoffset;
@@ -61,7 +61,7 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp)
if (stroffset < 0)
goto fail;
if (can_assume(LATEST) || fdt_version(fdt) >= 17) {
- if (stroffset >= fdt_size_dt_strings(fdt))
+ if ((unsigned)stroffset >= fdt_size_dt_strings(fdt))
goto fail;
if ((fdt_size_dt_strings(fdt) - stroffset) < len)
len = fdt_size_dt_strings(fdt) - stroffset;
More information about the vc
mailing list