lib: TYPE_IS_SIGNED macro generates compiler warnings.
authorEthan Jackson <ethan@nicira.com>
Tue, 13 Sep 2011 20:27:38 +0000 (13:27 -0700)
committerEthan Jackson <ethan@nicira.com>
Tue, 13 Sep 2011 21:29:41 +0000 (14:29 -0700)
The TYPE_IS_SIGNED macro does a less than zero comparision with an
unsigned type which can cause compiler warnings like the following:

lib/tag.c:100:9: error: comparison of unsigned expression < 0 is
always false [-Werror=type-limits]

lib/type-props.h

index 9225041..5c75d9f 100644 (file)
@@ -20,7 +20,7 @@
 #include <limits.h>
 
 #define TYPE_IS_INTEGER(TYPE) ((TYPE) 1.5 == (TYPE) 1)
-#define TYPE_IS_SIGNED(TYPE) ((TYPE) 0 > (TYPE) -1)
+#define TYPE_IS_SIGNED(TYPE) ((TYPE) 1 > (TYPE) -1)
 #define TYPE_VALUE_BITS(TYPE) (sizeof(TYPE) * CHAR_BIT - TYPE_IS_SIGNED(TYPE))
 #define TYPE_MINIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \
                             ? ~(TYPE)0 << TYPE_VALUE_BITS(TYPE) \