summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2017-07-20 16:59:32 +0200
committerNiels de Vos <ndevos@redhat.com>2017-07-22 17:52:54 +0000
commited6efab247b48c2c543a59c6d7adc30848d4a821 (patch)
tree709e5c296cc5039cb809dfe78c1440cd3bd88d86 /libglusterfs
parent6b89b8cee79aa54ded4c34d3209c54ed674b1364 (diff)
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 <ndevos@redhat.com> Reviewed-on: https://review.gluster.org/17842 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/common-utils.h4
1 files changed, 2 insertions, 2 deletions
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