[ccan] [PATCH 3/5] idtree: Fix comparison is always false warning

David Gibson david at gibson.dropbear.id.au
Thu Jan 28 00:53:30 AEDT 2016


idtree.c:146 triggers a "comparison is always false" warning on some
compiler configurations, since the 'id' variable is unsigned.

Elsewhere in the module ids seem to be represented by (signed) ints, so
use the same convention here, suppressing the warning and also maybe being
more correct in other ways.

Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 ccan/idtree/idtree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ccan/idtree/idtree.c b/ccan/idtree/idtree.c
index e887392..48add6a 100644
--- a/ccan/idtree/idtree.c
+++ b/ccan/idtree/idtree.c
@@ -100,7 +100,8 @@ static int sub_alloc(struct idtree *idp, const void *ptr, int *starting_id)
 	int n, m, sh;
 	struct idtree_layer *p, *pn;
 	struct idtree_layer *pa[MAX_LEVEL+1];
-	unsigned int l, id, oid;
+	unsigned int l;
+	int id, oid;
 	uint32_t bm;
 
 	memset(pa, 0, sizeof(pa));
-- 
2.5.0



More information about the ccan mailing list