idtree: fix right shift of signed ints
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 6 Dec 2010 03:12:00 +0000 (13:42 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 6 Dec 2010 03:12:00 +0000 (13:42 +1030)
commit9ad912e2583efd7d9927b0155688f9bc5291efdb
tree547b9b42da643a228aa1fca9ed69d72ae9b3916f
parent6994f3d0b1fefa78443253b6b9bf4db15f29b3f3
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 <cc@us.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/idtree/idtree.c