|
Message-Id: <6DCAE4F8-3BEC-45F2-A733-F4D15850B7F3@dilger.ca>
Date: Tue, 11 Jun 2019 15:00:10 -0600
From: Andreas Dilger <adilger@...ger.ca>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Shyam Saini <shyam.saini@...rulasolutions.com>,
kernel-hardening@...ts.openwall.com,
linux-kernel@...r.kernel.org,
keescook@...omium.org,
linux-arm-kernel@...ts.infradead.org,
linux-mips@...r.kernel.org,
intel-gvt-dev@...ts.freedesktop.org,
intel-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org,
netdev@...r.kernel.org,
linux-ext4 <linux-ext4@...r.kernel.org>,
devel@...ts.orangefs.org,
linux-mm@...ck.org,
linux-sctp@...r.kernel.org,
bpf@...r.kernel.org,
kvm@...r.kernel.org,
mayhs11saini@...il.com,
Alexey Dobriyan <adobriyan@...il.com>
Subject: Re: [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF
macro
On Jun 11, 2019, at 2:48 PM, Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Wed, 12 Jun 2019 01:08:36 +0530 Shyam Saini <shyam.saini@...rulasolutions.com> wrote:
>
>> Currently, there are 3 different macros, namely sizeof_field, SIZEOF_FIELD
>> and FIELD_SIZEOF which are used to calculate the size of a member of
>> structure, so to bring uniformity in entire kernel source tree lets use
>> FIELD_SIZEOF and replace all occurrences of other two macros with this.
>>
>> For this purpose, redefine FIELD_SIZEOF in include/linux/stddef.h and
>> tools/testing/selftests/bpf/bpf_util.h and remove its defination from
>> include/linux/kernel.h
>>
>> In favour of FIELD_SIZEOF, this patch also deprecates other two similar
>> macros sizeof_field and SIZEOF_FIELD.
>>
>> For code compatibility reason, retain sizeof_field macro as a wrapper macro
>> to FIELD_SIZEOF
>
> As Alexey has pointed out, C structs and unions don't have fields -
> they have members. So this is an opportunity to switch everything to
> a new member_sizeof().
>
> What do people think of that and how does this impact the patch footprint?
I did a check, and FIELD_SIZEOF() is used about 350x, while sizeof_field()
is about 30x, and SIZEOF_FIELD() is only about 5x.
That said, I'm much more in favour of "sizeof_field()" or "sizeof_member()"
than FIELD_SIZEOF(). Not only does that better match "offsetof()", with
which it is closely related, but is also closer to the original "sizeof()".
Since this is a rather trivial change, it can be split into a number of
patches to get approval/landing via subsystem maintainers, and there is no
huge urgency to remove the original macros until the users are gone. It
would make sense to remove SIZEOF_FIELD() and sizeof_field() quickly so
they don't gain more users, and the remaining FIELD_SIZEOF() users can be
whittled away as the patches come through the maintainer trees.
Cheers, Andreas
Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.