From ed6efab247b48c2c543a59c6d7adc30848d4a821 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 20 Jul 2017 16:59:32 +0200 Subject: libglusterfs: prevent compile warnings with roof() and floor() gcc 7 (default in Fedora 26) complains about the roof() and floor() macros: stripe.c: In function 'stripe_truncate': stripe.c:701:49: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context] tmp_offset = roof(offset, fctx->stripe_size * ../../../../libglusterfs/src/common-utils.h:55:35: note: in definition of macro 'roof' #define roof(a,b) ((((a)+(b)-1)/((b)?(b):1))*(b)) ^ stripe.c:704:50: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context] tmp_offset = floor(offset, fctx->stripe_size * ../../../../libglusterfs/src/common-utils.h:56:28: note: in definition of macro 'floor' #define floor(a,b) (((a)/((b)?(b):1))*(b)) ^ The calculations done in stripe_truncate() look safe enough, but gcc does not seem to like the passing the int/size_t to the `((b)?(b):1)` compact if-statement, so use `b != 0` for the test. Change-Id: If9fa4b8e86ba4b2ace61b1e05a5c28050fe4a7d3 Updates: #259 Signed-off-by: Niels de Vos Reviewed-on: https://review.gluster.org/17842 Smoke: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Raghavendra Talur CentOS-regression: Gluster Build System --- libglusterfs/src/common-utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 1d7f09dbc82..bfb36dfa83d 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -52,8 +52,8 @@ void trap (void); #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) -#define roof(a,b) ((((a)+(b)-1)/((b)?(b):1))*(b)) -#define floor(a,b) (((a)/((b)?(b):1))*(b)) +#define roof(a,b) ((((a)+(b)-1)/((b!=0)?(b):1))*(b)) +#define floor(a,b) (((a)/((b!=0)?(b):1))*(b)) #define IPv4_ADDR_SIZE 32 -- cgit