From 9c8a95b916897ce7c2f23aa9d254517699d5b8b1 Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Sat, 4 Feb 2017 00:41:46 +0900
Subject: [PATCH 4/5] init_crystal: kill gcc7 -Wint-in-bool-context

gcc7 -Wall now warns:
../../hacks/crystal.c:1009:31: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
../../hacks/crystal.c:97:30:
 #define NRAND(n)           ( (n) ? (int) (LRAND() % (n)) : 0)
                              ~~~
../../hacks/crystal.c:1009:31:
     cryst->offset_h = NRAND(2 * cryst->offset_h);
../../hacks/crystal.c:97:31: note: in definition of macro 'NRAND'
 #define NRAND(n)           ( (n) ? (int) (LRAND() % (n)) : 0)
                               ^

This warning means that the usage of "2 *" is highly questionable
because this multiplication does not change the result of boolean
result (unless such multiplication overflows - which is undefined).

However, in this case, such multiplicated value is used afterwards
(as a denominator), so this warning here is not meaningful.

But this warning can be easily eliminated, so let's fix this.
---
 hacks/crystal.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hacks/crystal.c b/hacks/crystal.c
index 9dfa5ea..efa7704 100644
--- a/hacks/crystal.c
+++ b/hacks/crystal.c
@@ -1005,8 +1005,13 @@ init_crystal(ModeInfo * mi)
 		cryst->offset_h = (int) ((cryst->win_height - cryst->b * cos((
 					cryst->gamma - 90) * PI_RAD)) / 2.0);
 		if (!centre) {
-			if (cryst->offset_h > 0)
-				cryst->offset_h = NRAND(2 * cryst->offset_h);
+			if (cryst->offset_h > 0) {
+				/* once put the multiplication result to another variable here
+				   to aviod warning from gcc7 -Wint-in-bool-context
+				 */
+				int denom = 2 * cryst->offset_h;
+				cryst->offset_h = NRAND(denom);
+			}
 			cryst->offset_w = (int) (cryst->win_width - cryst->a -
 						 cryst->b *
 				    fabs(sin((cryst->gamma - 90) * PI_RAD)));
-- 
2.11.1

