On Mon, Sep 21, 2020 at 05:53:03PM +0100, Andre Przywara wrote: > With -Wsign-compare, compilers warn about a mismatching signedness > in a comparison in fdt_strerror(). > > At this point we are sure that errval is negative, and since > FDT_ERRTABSIZE is surely positive, we can do some casting to make the > compiler happy. > > Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx> Since error values are typically conveyed as negative numbers (which is kind of the whole reason we have all these signed values in the first place), I think it would be slightly nicer to actually fold the case to signed into the definition of FDT_ERRTABSIZE. > --- > libfdt/fdt_strerror.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libfdt/fdt_strerror.c b/libfdt/fdt_strerror.c > index 768db66..efce51d 100644 > --- a/libfdt/fdt_strerror.c > +++ b/libfdt/fdt_strerror.c > @@ -48,7 +48,7 @@ const char *fdt_strerror(int errval) > return "<valid offset/length>"; > else if (errval == 0) > return "<no error>"; > - else if (errval > -FDT_ERRTABSIZE) { > + else if (errval > -(int)FDT_ERRTABSIZE) { > const char *s = fdt_errtable[-errval].str; > > if (s) -- 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