summaryrefslogtreecommitdiff
path: root/libfdt
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2020-10-01 17:46:26 +0100
committerDavid Gibson <david@gibson.dropbear.id.au>2020-10-02 10:28:36 +1000
commitf28aa271000bfeaa765b824a8a3e7b170da12925 (patch)
treecf0e386ff51a6d3e395c366b93e4b7f0caf6b948 /libfdt
parent3d7c6f44195a78dfa52b1b8c9efd7efd706b0dd9 (diff)
downloaddevice-tree-compiler-f28aa271000bfeaa765b824a8a3e7b170da12925.tar.gz
libfdt: fdt_move(): Fix comparison warnings
With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_move(). This stems from "bufsize" being passed in as a signed integer, even though we would expect a buffer size to be positive. Short of changing the prototype, check that bufsize is not negative, and cast it to an unsigned type in the comparison. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20201001164630.4980-3-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'libfdt')
-rw-r--r--libfdt/fdt.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index 04e1e06..6cf2fa0 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -314,9 +314,12 @@ const char *fdt_find_string_(const char *strtab, int tabsize, const char *s)
int fdt_move(const void *fdt, void *buf, int bufsize)
{
+ if (!can_assume(VALID_INPUT) && bufsize < 0)
+ return -FDT_ERR_NOSPACE;
+
FDT_RO_PROBE(fdt);
- if (fdt_totalsize(fdt) > bufsize)
+ if (fdt_totalsize(fdt) > (unsigned int)bufsize)
return -FDT_ERR_NOSPACE;
memmove(buf, fdt, fdt_totalsize(fdt));