From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Thomas Gleixner <tglx@linutronix.de>,
David Laight <david.laight.linux@gmail.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] fs: Replace user_access_{begin/end} by scoped user access
Date: Tue, 24 Mar 2026 12:42:40 +0100 [thread overview]
Message-ID: <b4565127-2ee3-4776-acea-ee47f65672ff@kernel.org> (raw)
In-Reply-To: <CAHk-=widw8GwXNuq5ALr+NgDDUN+=pc77U=EczqUiVZeD2Dz+Q@mail.gmail.com>
Le 18/03/2026 à 16:53, Linus Torvalds a écrit :
> On Wed, 18 Mar 2026 at 08:49, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>>
>> #define dirent_size(dirent, len) offsetof(typeof(dirent), d_name[len])
>
> That 'typeof(dirent)' needs to be 'typeof(*(dirent))' to be convenient.
>
> It was correct in the patch I attached, but I'll just point it out anyway.
>
> And we actually have a helper macro for that: struct_offset(). Which
> wasn't what I used in that attached patch, but *should* have been.
>
> IOW, the macro should look something like
>
> #define dirent_size(dirent, len) struct_offset(dirent, d_name[len])
>
Sending v5 (series of 2) with your suggested patch as patch 1.
Following feedback from David which I tend to agree with, I left it as
you did initialy.
struct_offset() has only one caller and I don't feel it has much added
value compared to offsetof(typeof(),) pattern which is more explicit and
already used 144 times in the kernel:
$ git grep "offsetof(typeof(" | wc -l
144
Christophe
prev parent reply other threads:[~2026-03-24 11:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 8:52 [PATCH v3] fs: Replace user_access_{begin/end} by scoped user access Christophe Leroy (CS GROUP)
2026-03-16 17:12 ` Linus Torvalds
2026-03-16 23:19 ` David Laight
2026-03-18 12:29 ` Christophe Leroy (CS GROUP)
2026-03-18 15:49 ` Linus Torvalds
2026-03-18 15:53 ` Linus Torvalds
2026-03-18 22:35 ` David Laight
2026-03-24 11:42 ` Christophe Leroy (CS GROUP) [this message]
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=b4565127-2ee3-4776-acea-ee47f65672ff@kernel.org \
--to=chleroy@kernel.org \
--cc=brauner@kernel.org \
--cc=david.laight.linux@gmail.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.