From: Mathieu Desnoyers Date: Tue, 8 Oct 2013 21:22:42 +0000 (-0400) Subject: gcc warning fixes: -Wsign-compare and -Wextra X-Git-Tag: v0.9.0~135 X-Git-Url: http://git.lttng.org/?p=userspace-rcu.git;a=commitdiff_plain;h=4b5f005b03669c2942969e691fc3a0be47b15c57;hp=4b5f005b03669c2942969e691fc3a0be47b15c57 gcc warning fixes: -Wsign-compare and -Wextra When compiling code using the rcu_xchg_pointer() family of functions, with the following define: #define URCU_INLINE_SMALL_FUNCTIONS prior to including urcu headers, when compiling with gcc with -Wsign-compare and -Wextra, gcc warns about: urcu-xchg.c: In function ‘reload’: urcu-xchg.c:19:1: warning: ordered comparison of pointer with integer zero [-Wextra] urcu-xchg.c:19:1: warning: signed and unsigned type in conditional expression [-Wsign-compare] For the "ordered comparison of pointer with integer zero" warning, fix this by comparing (type) -1 against (type) 0 instead of just 0, so if "type" is a pointer type, this pointer type will be applied to the right operand too, thus fixing the warning. For the "signed and unsigned type in conditional expression" warning, we need caa_cast_long_keep_sign() to always evaluate to the same type signedness. In order to do so, when we need to sign-extend the value, cast it to unsigned long after first casting it to long. Reported-by: Stephen Hemminger Signed-off-by: Mathieu Desnoyers ---