Skip to content

Commit

Permalink
libfdt: fdt_get_string(): Fix comparison warnings
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andre Przywara <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: David Gibson <[email protected]>
  • Loading branch information
sjg20 authored and dgibson committed Sep 24, 2020
1 parent f8e11e6 commit 54dca09
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libfdt/fdt_ro.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ 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;

if (fdt_magic(fdt) == FDT_MAGIC) {
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;
Expand Down

0 comments on commit 54dca09

Please sign in to comment.