linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shyam Saini <mayhs11saini@gmail.com>
To: William Kucharski <william.kucharski@oracle.com>
Cc: Shyam Saini <shyam.saini@amarulasolutions.com>,
	 Kernel Hardening <kernel-hardening@lists.openwall.com>,
	LKML <linux-kernel@vger.kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Kees Cook <keescook@chromium.org>,
	 linux-arm-kernel@lists.infradead.org,
	linux-mips@vger.kernel.org,  intel-gvt-dev@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org,
	 dri-devel <dri-devel@lists.freedesktop.org>,
	 Network Development <netdev@vger.kernel.org>,
	linux-ext4@vger.kernel.org,  devel@lists.orangefs.org,
	linux-mm <linux-mm@kvack.org>,
	linux-sctp@vger.kernel.org,  bpf <bpf@vger.kernel.org>,
	kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] include: linux: Regularise the use of FIELD_SIZEOF macro
Date: Sat, 20 Apr 2019 16:21:00 +0530	[thread overview]
Message-ID: <CAOfkYf7vn7UnYzZDh9==agVu61sYyFWzvo6hQBt3KfaKrWC-6Q@mail.gmail.com> (raw)
In-Reply-To: <C398B8C9-6A54-4590-AA88-58D514BAEB71@oracle.com>

Hi William,

Sorry for the late reply.

> > 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
>
>
> > --- a/include/linux/stddef.h
> > +++ b/include/linux/stddef.h
> > @@ -20,6 +20,15 @@ enum {
> > #endif
> >
> > /**
> > + * FIELD_SIZEOF - get the size of a struct's field
> > + * @t: the target struct
> > + * @f: the target struct's field
> > + * Return: the size of @f in the struct definition without having a
> > + * declared instance of @t.
> > + */
> > +#define FIELD_SIZEOF(t, f) (sizeof(((t *)0)->f))
> > +
> > +/**
> >  * sizeof_field(TYPE, MEMBER)
> >  *
> >  * @TYPE: The structure containing the field of interest
> > @@ -34,6 +43,6 @@ enum {
> >  * @MEMBER: The member within the structure to get the end offset of
> >  */
> > #define offsetofend(TYPE, MEMBER) \
> > -     (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
> > +     (offsetof(TYPE, MEMBER) + FIELD_SIZEOF(TYPE, MEMBER))
>
> If you're doing this, why are you leaving the definition of sizeof_field() in
> stddef.h untouched?

I have removed definition of sizeof_field in [1/2] patch.

> Given the way this has worked historically, if you are leaving it in place for
> source compatibility reasons, shouldn't it be redefined in terms of
> FIELD_SIZEOF(), e.g.:
>
> #define sizeof_field(TYPE, MEMBER) FIELD_SIZEOF(TYPE, MEMBER)

Actually, never thought this way. So,Thanks a lot for this valuable feedback.

I'll re-spin and post again.


      reply	other threads:[~2019-04-20 10:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-14  9:14 Shyam Saini
2019-04-14  9:14 ` [PATCH 2/2] include: linux: Remove unused macros and their defination Shyam Saini
2019-04-15  5:43 ` [PATCH 1/2] include: linux: Regularise the use of FIELD_SIZEOF macro Alexei Starovoitov
2019-04-15  7:13   ` Shyam Saini
2019-04-15 10:12 ` William Kucharski
2019-04-20 10:51   ` Shyam Saini [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='CAOfkYf7vn7UnYzZDh9==agVu61sYyFWzvo6hQBt3KfaKrWC-6Q@mail.gmail.com' \
    --to=mayhs11saini@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bpf@vger.kernel.org \
    --cc=devel@lists.orangefs.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shyam.saini@amarulasolutions.com \
    --cc=william.kucharski@oracle.com \
    /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