[PATCH 12/14] libfdt: fdt_get_string(): Fix sequential write comparison warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



With -Wsign-compare, compilers warn about a mismatching signedness in
comparisons in fdt_get_string().

The two occassions dealing with the sequential write case are a bit
tricky, since we deliberately abuse the negative values here.

As we have just established that stroffset is negative, we can use
casts to appease the compiler.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
---
 libfdt/fdt_ro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index ddb5a2d..059d302 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -68,9 +68,9 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp)
 		}
 	} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
 		if ((stroffset >= 0)
-		    || (stroffset < -fdt_size_dt_strings(fdt)))
+		    || (stroffset < -(int)fdt_size_dt_strings(fdt)))
 			goto fail;
-		if ((-stroffset) < len)
+		if ((unsigned)(-stroffset) < len)
 			len = -stroffset;
 	} else {
 		err = -FDT_ERR_INTERNAL;
-- 
2.17.5




[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux