Re: [RFC PATCH 05/13] list.h: Fix parentheses around macro pointer parameter use

From: Andy Shevchenko
Date: Fri May 12 2023 - 07:02:29 EST


On Mon, May 08, 2023 at 09:46:40AM -0400, Mathieu Desnoyers wrote:
> On 2023-05-08 08:16, Andy Shevchenko wrote:

...

> The only use I found that would break is as follows:
>
> LIST_HEAD(testlist);
>
> int f2(void)
> {
> return 1;
> }
>
> #define eval(...) __VA_ARGS__
>
> void f(void)
> {
> struct list_head *pos;
>
> list_for_each(pos, eval(f2(), &testlist)) {
> //...
> }
> }
>
> Because "eval()" will evaluate "f(), &testlist" with comma and all, without
> enclosing parentheses.
>
> So the question is: do we want to support this kind-of-odd macro evaluation,
> considering that it requires adding parentheses around pretty much all macro
> parameters when used as expressions between commas?

Similar question can be asked for your initial motivation to support indirect
pointers. I found the double pointer as weird as this macro case. But it can be
only me. Hence I left this to the more experienced developers to express their
opinions.

--
With Best Regards,
Andy Shevchenko