talloc: fix compiler warning
authorStefan Metzmacher <metze@samba.org>
Wed, 20 Nov 2013 08:58:09 +0000 (09:58 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 16 May 2014 15:21:04 +0000 (17:21 +0200)
This avoids the following warning when using:

CFLAGS="-O3 -g -fstrict-overflow -Wstrict-overflow=5"

../talloc.c: In Funktion Ā»talloc_is_parentĀ«:
../talloc.c:2658:21: Warnung: assuming signed overflow does not occur when
changing X +- C1 cmp C2 to X cmp C1 +- C2 [-Wstrict-overflow]

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/talloc/talloc.c

index 3b8cb81df4a2a79744e1abb6a5baefaf8f4ea3e8..fa56ea5678061a21c7e38f25ed5463921d79e761 100644 (file)
@@ -2655,7 +2655,10 @@ static int _talloc_is_parent(const void *context, const void *ptr, int depth)
        }
 
        tc = talloc_chunk_from_ptr(context);
-       while (tc && depth > 0) {
+       while (tc) {
+               if (depth <= 0) {
+                       return 0;
+               }
                if (TC_PTR_FROM_CHUNK(tc) == ptr) return 1;
                while (tc && tc->prev) tc = tc->prev;
                if (tc) {