[hackers] [dmenu][PATCH] Remove warning for int comparison as bool

From: Prathu Baronia <prathu.baronia_AT_praton.me>
Date: Fri, 25 Feb 2022 11:07:49 +0530

- Compare the result of the macro with 0 instead of treating as bool to remove
  the following warning.

dmenu.c: In function ‘setup’:
dmenu.c:24:30: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
   23 | #define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   24 | * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dmenu.c:655:37: note: in expansion of macro ‘INTERSECT’
  655 | if (INTERSECT(x, y, 1, 1, info[i]))
      | ^~~~~~~~~

Signed-off-by: Prathu Baronia <prathu.baronia_AT_praton.me>
---
 dmenu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dmenu.c b/dmenu.c
index d95e6c6..81b8567 100644
--- a/dmenu.c
+++ b/dmenu.c
_AT_@ -652,7 +652,7 @@ setup(void)
 		/* no focused window is on screen, so use pointer location instead */
 		if (mon < 0 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du))
 			for (i = 0; i < n; i++)
-				if (INTERSECT(x, y, 1, 1, info[i]))
+				if (INTERSECT(x, y, 1, 1, info[i]) > 0)
 					break;
 
 		x = info[i].x_org;
-- 
2.35.1
Received on Fri Feb 25 2022 - 06:37:49 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 25 2022 - 06:48:36 CET