]> granicus.if.org Git - gc/commitdiff
Workaround 'comparison is always false' GCC warning in GC_FAST_MALLOC_GRANS
authorIvan Maidanski <ivmai@mail.ru>
Mon, 28 Dec 2015 14:49:54 +0000 (17:49 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 28 Dec 2015 14:49:54 +0000 (17:49 +0300)
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Refactoring of condition
expression for entry containing counter or is NULL to avoid
"comparison of unsigned expression < 0 is always false" warning
reported by GCC.

include/gc_inline.h

index 8d93f44acc4ca5e497a4f017d10f6d2f1d492e6c..90a7a761962fada685f487bdb21548681a0d6f93 100644 (file)
@@ -79,7 +79,7 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t /* lb */, int /* k */,
         while (GC_EXPECT((GC_word)my_entry \
                         <= (num_direct) + GC_TINY_FREELISTS + 1, 0)) { \
             /* Entry contains counter or NULL */ \
-            if ((GC_word)my_entry - 1 < (num_direct)) { \
+            if ((GC_word)my_entry <= (num_direct) && my_entry != 0) { \
                 /* Small counter value, not NULL */ \
                 *my_fl = (char *)my_entry + (granules) + 1; \
                 result = (default_expr); \