gcc warning fixes: -Wsign-compare and -Wextra
[userspace-rcu.git] / urcu / compiler.h
index cd4a49d19dc6e82f454027bfba76dc2f8eb14bf5..0032b60cf67b64ee9bb349efdfaf17e8c34aba3a 100644 (file)
 #define URCU_FORCE_CAST(type, arg)     ((type) (arg))
 #endif
 
-#define caa_is_signed_type(type)       (((type) (-1)) < 0)
+#define caa_is_signed_type(type)       ((type) -1 < (type) 0)
 
-#define caa_cast_long_keep_sign(v)     \
-       (caa_is_signed_type(__typeof__(v)) ? (long) (v) : (unsigned long) (v))
+/*
+ * Sign-extend to long if needed, and output type is unsigned long.
+ */
+#define caa_cast_long_keep_sign(v)             \
+       (caa_is_signed_type(__typeof__(v)) ?    \
+               (unsigned long) (long) (v) :    \
+               (unsigned long) (v))
 
 #endif /* _URCU_COMPILER_H */
This page took 0.022834 seconds and 4 git commands to generate.