libfdt: fdt_get_string(): Fix sequential write comparison warnings
With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_get_string(). Introduce a new usigned variable, which holds the actual (negated) stroffset value, so we avoid negating all the other variables and have proper types everywhere. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20201001164630.4980-6-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
committed by
David Gibson
parent
82525f41d5
commit
6c2be7d853
@@ -67,11 +67,13 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp)
|
|||||||
len = fdt_size_dt_strings(fdt) - stroffset;
|
len = fdt_size_dt_strings(fdt) - stroffset;
|
||||||
}
|
}
|
||||||
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
|
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
|
||||||
if ((stroffset >= 0)
|
unsigned int sw_stroffset = -stroffset;
|
||||||
|| (stroffset < -fdt_size_dt_strings(fdt)))
|
|
||||||
|
if ((stroffset >= 0) ||
|
||||||
|
(sw_stroffset > fdt_size_dt_strings(fdt)))
|
||||||
goto fail;
|
goto fail;
|
||||||
if ((-stroffset) < len)
|
if (sw_stroffset < len)
|
||||||
len = -stroffset;
|
len = sw_stroffset;
|
||||||
} else {
|
} else {
|
||||||
err = -FDT_ERR_INTERNAL;
|
err = -FDT_ERR_INTERNAL;
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|||||||
Reference in New Issue
Block a user