Makefile: WARNINGS: add -Wlogical-op
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 29 May 2012 10:09:32 +0000 (12:09 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 29 May 2012 13:19:32 +0000 (15:19 +0200)
-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 <ferry.huberts@pelagic.nl>
Makefile.inc
src/fpm.c

index 8b8f31a..b817e6d 100644 (file)
@@ -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
index ad66a1a..ca98c6e 100644 (file)
--- 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;
 }