On Mon, Nov 18, 2019 at 08:40:58AM +0100, Heinrich Schuchardt wrote: > For GCC 9.2.1 the negative of an unsigned size_t value is again an unsigned > size_t value, e.g. -5UL = 18446744073709551611UL. > > Correct the logical constraint. Add necessary type conversions. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@xxxxxx> > --- > It would be advisable to add -Wextra to the libfdt Makefile after > correcting the 50+ -Wsign-compare problems reported. > --- > 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 adab0cb..b69806f 100644 > --- a/libfdt/fdt_ro.c > +++ b/libfdt/fdt_ro.c > @@ -59,9 +59,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))) > + || ((size_t)-stroffset > fdt_size_dt_strings(fdt))) Hmm. Why is the explicit cast necessary? -stroffset is definitely positive (because of the test above), so shouldn't it be promoted correctly here? > goto fail; > - if ((-stroffset) < len) > + if ((size_t)-stroffset < len) Same here. > len = -stroffset; > } else { > err = -FDT_ERR_INTERNAL; -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature