mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@intel.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [RFC PATCH 4/4] llist.h: Fix parentheses around macro pointer parameter use
Date: Fri, 05 May 2023 09:38:54 +0800	[thread overview]
Message-ID: <87354bd0b5.fsf@yhuang6-desk2.ccr.corp.intel.com> (raw)
In-Reply-To: <CAHk-=wjfgCa-u8h9z+8U7gaKK6PnRCpws1Md9wYSSXywUxoUSA@mail.gmail.com> (Linus Torvalds's message of "Thu, 4 May 2023 10:16:36 -0700")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Thu, May 4, 2023 at 7:54 AM Mathieu Desnoyers
> <mathieu.desnoyers@efficios.com> wrote:
>> +#define list_prepare_entry(pos, head, member) \
>> +       ((pos) ? : list_entry(head, typeof(*pos), member))
>>
>> So even though the fact that "pos" is used as an lvalue specifically in
>> llist_for_each_entry_safe() makes it so that the parentheses are not
>> strictly required around "pos" in typeof(*pos), I argue that we should
>> still add those for consistency.
>
> Ack. It may not matter in reality because of how 'pos' is supposed to
> be just a local variable name, but I agree that for consistency our
> macros should still follow the usual pattern.
>
> Of course, *because* of how 'pos' is not some random expression, and
> is supposed to be that local variable, and because of how it is used,
> it must always violate the whole "only use once" usual pattern,.
>
> Exactly the same way the member name is also typically used multiple
> times because of how it's not an expression, but really a "part of the
> syntax".
>
> So an alternative might be that we should use a different syntax for
> those things and make it clear that they are not normal expressions.
> Some people use upper-case names for special things like that to make
> them stand out as "not normal" (kind of the same way upper-case macros
> themselves were a warning that they weren't normal and might evaluate
> arguments multiple times).

This sounds a good idea for me.

And with this, I think that we will use typeof(*POS) instead of
typeof(*(pos))?

Best Regards,
Huang, Ying

  reply	other threads:[~2023-05-05  1:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-04  1:29 [RFC PATCH 1/4] rcu: rcupdate.h: Add missing parentheses around macro pointer dereference Mathieu Desnoyers
2023-05-04  1:29 ` [RFC PATCH 2/4] list.h: Fix parentheses around macro pointer parameter use Mathieu Desnoyers
2023-05-04 14:41   ` Andy Shevchenko
2023-05-04 14:45     ` Mathieu Desnoyers
2023-05-04  1:29 ` [RFC PATCH 3/4] rculist.h: " Mathieu Desnoyers
2023-05-04 16:19   ` Joel Fernandes
2023-05-05 14:06     ` Steven Rostedt
2023-05-05 14:35       ` Joel Fernandes
2023-05-05 15:02         ` Steven Rostedt
2023-05-04  1:29 ` [RFC PATCH 4/4] llist.h: " Mathieu Desnoyers
2023-05-04  5:54   ` Huang, Ying
2023-05-04 14:54     ` Mathieu Desnoyers
2023-05-04 17:16       ` Linus Torvalds
2023-05-05  1:38         ` Huang, Ying [this message]
2023-05-05 14:23         ` Mathieu Desnoyers
2023-05-05 18:08           ` Linus Torvalds
2023-05-06  1:12           ` Huang, Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87354bd0b5.fsf@yhuang6-desk2.ccr.corp.intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®