[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 5 May 2023 16:28:47 -0400
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, Jens Axboe <axboe@...nel.dk>,
linux-block@...r.kernel.org
Subject: Re: [RFC PATCH 12/13] blk-mq.h: Fix parentheses around macro
parameter use
On 2023-05-05 16:22, Linus Torvalds wrote:
> On Fri, May 5, 2023 at 1:08 PM Mathieu Desnoyers
> <mathieu.desnoyers@...icios.com> wrote:
>>
>> The reason why I think the lvalue of a "=" operator can be argued to be
>> "special" is because it is simply invalid to apply many of the C
>> operators to an lvalue (e.g. +, -, /, ...),
>
> Mathieu, you are simply objectively wrong.
>
> See here:
>
> #define m1(x) (x = 2)
> #define m2(x) ((x) = 2)
>
> and then try using the argument "a = b" to those macros.
>
> Guess which one flags it as an error ("lvalue required") and which one does not?
I'm glad you are proving me wrong. So it was just a lack of imagination
on my end.
>
> m2 is the only "good" one. Yes, m1 works in 99% of all cases in
> practice, but if you want a safer macro, you *will* add the
> parentheses.
>
> So *STOP*ARGUING* based on an incorrect "lowest precedence" basis.
> Even for the "lowest precedence" case, you have the *same* precedence.
Yes, your example clearly shows it.
> The fact is, assignment is not in any way special operation in macros,
> and does not deserve - and should absolutely not have - any special
> "doesn't need parentheses around argument" rules.
Good point. You are right. So that strongly supports the parentheses
around use of parameters as lvalues. One less special-case to care
about, which is great.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
Powered by blists - more mailing lists