[PATCH 1/1] libfdt: incorrect logical constraint in fdt_node_offset_by_phandle()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



A uint32_t value can never be negative. So (phandle == -1) is always false.

Add the missing type conversion.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@xxxxxx>
---
It would be advisable to add -Wextra to the Makefile after correcting
the 50+ -Wsign-compare problems reported.
---
 libfdt/fdt_ro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index a5c2797..adab0cb 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -658,7 +658,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
 {
 	int offset;

-	if ((phandle == 0) || (phandle == -1))
+	if ((phandle == 0) || ((int32_t)phandle == -1))
 		return -FDT_ERR_BADPHANDLE;

 	FDT_RO_PROBE(fdt);
--
2.24.0




[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux