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

From: Prathu Baronia <prathu.baronia_AT_praton.me>
Date: Wed, 2 Mar 2022 10:37:46 +0530

On 02-03-2022 03:18, Hiltjo Posthuma wrote:
> 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!
>
Sure Hiltjo. Thanks for maintaining this awesome project.

Regards,

Prathu
Received on Wed Mar 02 2022 - 06:07:46 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 02 2022 - 07:00:36 CET