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

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Tue, 1 Mar 2022 22:48:13 +0100

On Fri, Feb 25, 2022 at 11:07:49AM +0530, Prathu Baronia wrote:
> - 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
>
>

Hi Prathu,

I slightly changed the patch to != 0 and pushed it, thanks!

-- 
Kind regards,
Hiltjo
Received on Tue Mar 01 2022 - 22:48:13 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 01 2022 - 22:48:41 CET