[Olsr-dev] [PATCH v1 09/12] Makefile: WARNINGS: add -Wlogical-op

Ferry Huberts (spam-protected)
Tue May 29 15:59:38 CEST 2012


From: Ferry Huberts <(spam-protected)>

-Wlogical-op
  Warn about suspicious uses of logical operators in expressions.
  This includes using logical operators in contexts where a
  bit-wise operator is likely to be expected.

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 Makefile.inc |    1 +
 src/fpm.c    |    4 +++-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index 8b8f31a..b817e6d 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -96,6 +96,7 @@ WARNINGS +=	-Winit-self
 WARNINGS +=	-Wswitch-default
 WARNINGS +=	-Wsync-nand
 WARNINGS +=	-Wundef
+WARNINGS +=	-Wlogical-op
 # the following 2 do not work yet and need more work on it
 #WARNINGS +=	-Wconversion
 #WARNINGS +=	-Wredundant-decls
diff --git a/src/fpm.c b/src/fpm.c
index ad66a1a..ca98c6e 100644
--- a/src/fpm.c
+++ b/src/fpm.c
@@ -111,7 +111,9 @@ fpm
 fpmdiv(fpm a, fpm b)
 {
   fpm r;
-  assert(FPM_INT_MIN <= ((long long)(sfpm) a << FPM_BIT) && ((long long)(sfpm) a << FPM_BIT) <= FPM_INT_MAX);
+  long long tmp = ((long long)(sfpm) a << FPM_BIT);
+  assert(FPM_INT_MIN <= tmp);
+  assert(tmp <= FPM_INT_MAX);
   r = (fpm) fpmdiv_def((sfpm) a, (sfpm) b);
   return r;
 }
-- 
1.7.7.6





More information about the Olsr-dev mailing list