|
|
e09d503 |
From 9c8a95b916897ce7c2f23aa9d254517699d5b8b1 Mon Sep 17 00:00:00 2001
|
|
|
e09d503 |
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
|
|
|
e09d503 |
Date: Sat, 4 Feb 2017 00:41:46 +0900
|
|
|
e09d503 |
Subject: [PATCH 4/5] init_crystal: kill gcc7 -Wint-in-bool-context
|
|
|
e09d503 |
|
|
|
e09d503 |
gcc7 -Wall now warns:
|
|
|
e09d503 |
../../hacks/crystal.c:1009:31: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
|
|
|
e09d503 |
../../hacks/crystal.c:97:30:
|
|
|
e09d503 |
#define NRAND(n) ( (n) ? (int) (LRAND() % (n)) : 0)
|
|
|
e09d503 |
~~~
|
|
|
e09d503 |
../../hacks/crystal.c:1009:31:
|
|
|
e09d503 |
cryst->offset_h = NRAND(2 * cryst->offset_h);
|
|
|
e09d503 |
../../hacks/crystal.c:97:31: note: in definition of macro 'NRAND'
|
|
|
e09d503 |
#define NRAND(n) ( (n) ? (int) (LRAND() % (n)) : 0)
|
|
|
e09d503 |
^
|
|
|
e09d503 |
|
|
|
e09d503 |
This warning means that the usage of "2 *" is highly questionable
|
|
|
e09d503 |
because this multiplication does not change the result of boolean
|
|
|
e09d503 |
result (unless such multiplication overflows - which is undefined).
|
|
|
e09d503 |
|
|
|
e09d503 |
However, in this case, such multiplicated value is used afterwards
|
|
|
e09d503 |
(as a denominator), so this warning here is not meaningful.
|
|
|
e09d503 |
|
|
|
e09d503 |
But this warning can be easily eliminated, so let's fix this.
|
|
|
e09d503 |
---
|
|
|
e09d503 |
hacks/crystal.c | 9 +++++++--
|
|
|
e09d503 |
1 file changed, 7 insertions(+), 2 deletions(-)
|
|
|
e09d503 |
|
|
|
e09d503 |
diff --git a/hacks/crystal.c b/hacks/crystal.c
|
|
|
e09d503 |
index 9dfa5ea..efa7704 100644
|
|
|
e09d503 |
--- a/hacks/crystal.c
|
|
|
e09d503 |
+++ b/hacks/crystal.c
|
|
|
e09d503 |
@@ -1005,8 +1005,13 @@ init_crystal(ModeInfo * mi)
|
|
|
e09d503 |
cryst->offset_h = (int) ((cryst->win_height - cryst->b * cos((
|
|
|
e09d503 |
cryst->gamma - 90) * PI_RAD)) / 2.0);
|
|
|
e09d503 |
if (!centre) {
|
|
|
e09d503 |
- if (cryst->offset_h > 0)
|
|
|
e09d503 |
- cryst->offset_h = NRAND(2 * cryst->offset_h);
|
|
|
e09d503 |
+ if (cryst->offset_h > 0) {
|
|
|
e09d503 |
+ /* once put the multiplication result to another variable here
|
|
|
e09d503 |
+ to aviod warning from gcc7 -Wint-in-bool-context
|
|
|
e09d503 |
+ */
|
|
|
e09d503 |
+ int denom = 2 * cryst->offset_h;
|
|
|
e09d503 |
+ cryst->offset_h = NRAND(denom);
|
|
|
e09d503 |
+ }
|
|
|
e09d503 |
cryst->offset_w = (int) (cryst->win_width - cryst->a -
|
|
|
e09d503 |
cryst->b *
|
|
|
e09d503 |
fabs(sin((cryst->gamma - 90) * PI_RAD)));
|
|
|
e09d503 |
--
|
|
|
e09d503 |
2.11.1
|
|
|
e09d503 |
|