From 9ad912e2583efd7d9927b0155688f9bc5291efdb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 6 Dec 2010 13:42:00 +1030 Subject: [PATCH] idtree: fix right shift of signed ints (Imported from SAMBA commit 2db1987f5a3a) Right-shifting signed integers in undefined; indeed it seems that on AIX with their compiler, doing a 30-bit shift on (INT_MAX-200) gives 0, not 1 as we might expect (THIS WAS WRONG, REAL FIX LATER). The obvious fix is to make id and oid unsigned: l (level count) is also logically unsigned. (Note: Samba doesn't generally get to ids > 1 billion, but ctdb does) Reported-by: Chris Cowan Signed-off-by: Rusty Russell --- ccan/idtree/idtree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccan/idtree/idtree.c b/ccan/idtree/idtree.c index bc7ba5fc..5a26234e 100644 --- a/ccan/idtree/idtree.c +++ b/ccan/idtree/idtree.c @@ -100,7 +100,7 @@ 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]; - int l, id, oid; + unsigned int l, id, oid; uint32_t bm; memset(pa, 0, sizeof(pa)); -- 2.39.2