From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andre Przywara Subject: [PATCH 08/14] libfdt: fdt_create_with_flags(): Fix comparison warning Date: Mon, 21 Sep 2020 17:52:57 +0100 Message-ID: <20200921165303.9115-9-andre.przywara@arm.com> References: <20200921165303.9115-1-andre.przywara@arm.com> Return-path: In-Reply-To: <20200921165303.9115-1-andre.przywara-5wv7dgnIgG8@public.gmane.org> List-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Simon Glass , David Gibson Cc: Devicetree Compiler , Varun Wadekar With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_create_with_flags(). We have just established that bufsize is not negative, so a cast to an unsigned type is safe. Signed-off-by: Andre Przywara --- libfdt/fdt_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c index d65e9c8..8a76adf 100644 --- a/libfdt/fdt_sw.c +++ b/libfdt/fdt_sw.c @@ -112,7 +112,7 @@ int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags) sizeof(struct fdt_reserve_entry)); void *fdt = buf; - if (bufsize < hdrsize) + if (bufsize < 0 || (unsigned)bufsize < hdrsize) return -FDT_ERR_NOSPACE; if (flags & ~FDT_CREATE_FLAGS_ALL) -- 2.17.5