]> git.ozlabs.org Git - ccan/blobdiff - ccan/idtree/idtree.c
idtree: Fix undefined behaviour (left shift of signed value)
[ccan] / ccan / idtree / idtree.c
index 48add6a8ac4fa917751ac92a06709a730b9e0ba6..6e75450e67e85af287a9967cd7e88af66e147a5b 100644 (file)
@@ -135,7 +135,7 @@ restart:
                         */
                        sh = IDTREE_BITS * (l + 1);
                        if (oid >> sh == id >> sh)
-                       continue;
+                               continue;
                        else
                                goto restart;
                }
@@ -278,7 +278,7 @@ void *idtree_lookup(const struct idtree *idp, int id)
         * present.  If so, tain't one of ours!
         */
        if (n + IDTREE_BITS < 31 &&
-           (id & ~(~0 << MAX_ID_SHIFT)) >> (n + IDTREE_BITS))
+           (id & ~(~0U << MAX_ID_SHIFT)) >> (n + IDTREE_BITS))
             return NULL;
 
        /* Mask off upper bits we don't use for the search. */