All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: "Pierre-Clément Tosi" <ptosi@google.com>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
	Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH 7/9] include: Upgrade <linux/typecheck.h>
Date: Mon, 28 Mar 2022 00:35:05 -0600	[thread overview]
Message-ID: <CAPnjgZ04RnRbHsUXqOFH=+b-Zbc3jx0kHVMDpFAHsYwCgdx_9A@mail.gmail.com> (raw)
In-Reply-To: <20220317114636.v2hmcmn564odjzjt@google.com>

Hi Pierre-Clément,

On Thu, 17 Mar 2022 at 05:46, Pierre-Clément Tosi <ptosi@google.com> wrote:
>
> On Wed, Mar 16, 2022 at 01:23:38PM -0600, Simon Glass wrote:
> > Hi,
> >
> > On Wed, 16 Mar 2022 at 09:41, Pierre-Clément Tosi <ptosi@google.com> wrote:
> > >
> > > Upgrade the header to version 5.16 of the kernel:
> > >
> > >     commit df0cc57e057f18e44dac8e6c18aba47ab53202f9
> > >
> > > Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
> > > Cc: Simon Glass <sjg@chromium.org>
> > > Cc: Tom Rini <trini@konsulko.com>
> > > ---
> > >  include/linux/typecheck.h | 10 ++++++++++
> > >  1 file changed, 10 insertions(+)
> >
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> >
> > But I don't understand how this works at all. Could you add a comment?
>
> This patch is a simple upgrade of the header. I needed it for another patch
> stack and, given how trivial and self-contained it is, I thought I would slip it
> into this one.
>
> If your "this" refers to the macro itself, an error should be generated by the
> compiler when dereferencing a non-pointer and it avoids introducing side effects
> through the use of __dummy but I'm not sure what the sizeof is there for; is it
> perhaps compliant for an implementation to keep generating code when
> encountering a dereferenced non-pointer (leading to a bogus result, from UB) so
> that sizeof forces it to depend on that expression being of a valid type? Or is
> it to do with catching variables of incomplete type e.g. arrays of unknown size?
> It was introduced by commit cb0f80039fb7 ("bitops: Add non-atomic bitops for
> pointers"), which doesn't provide much information either.

Hmm OK. The Linux people are quite averse to comments. If you have
time you could send a patch to comment the macro and see if someone
responds and dispels the uncertainty.

>
> >
> > >
> > > diff --git a/include/linux/typecheck.h b/include/linux/typecheck.h
> > > index eb5b74a575..46b15e2aae 100644
> > > --- a/include/linux/typecheck.h
> > > +++ b/include/linux/typecheck.h
> > > @@ -1,3 +1,4 @@
> > > +/* SPDX-License-Identifier: GPL-2.0 */
> > >  #ifndef TYPECHECK_H_INCLUDED
> > >  #define TYPECHECK_H_INCLUDED
> > >
> > > @@ -21,4 +22,13 @@
> > >         (void)__tmp; \
> > >  })
> > >
> > > +/*
> > > + * Check at compile time that something is a pointer type.
> > > + */
> > > +#define typecheck_pointer(x) \
> > > +({     typeof(x) __dummy; \
> > > +       (void)sizeof(*__dummy); \
> > > +       1; \
> > > +})
> > > +
> > >  #endif         /* TYPECHECK_H_INCLUDED */
> > > --
> > > 2.35.1.723.g4982287a31-goog
Regards,
Simon

  reply	other threads:[~2022-03-28  6:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16 15:39 [PATCH 1/9] net: gmac_rockchip: Fix misuse of GENMASK macro Pierre-Clément Tosi
2022-03-16 15:39 ` [PATCH 2/9] lib: crypt: Avoid redefining static_assert Pierre-Clément Tosi
2022-03-16 19:23   ` Simon Glass
2022-03-16 19:41     ` Steffen Jaeckel
2022-03-16 15:39 ` [PATCH 3/9] scripts: Makefile.lib: Pass __UBOOT__ to DTC's CPP Pierre-Clément Tosi
2022-03-16 19:23   ` Simon Glass
2022-03-17 10:42     ` Pierre-Clément Tosi
2022-03-16 15:39 ` [PATCH 4/9] linux/const.h: Upgrade & Merge vDSO and uAPI Pierre-Clément Tosi
2022-03-16 19:23   ` Simon Glass
2022-03-17 11:00     ` Pierre-Clément Tosi
2022-03-28  6:35       ` Simon Glass
2022-03-16 15:39 ` [PATCH 5/9] include: Import <linux/bits.h> & Update bitops.h Pierre-Clément Tosi
2022-03-16 19:23   ` Simon Glass
2022-03-16 15:39 ` [PATCH 6/9] include: Carve <linux/export.h> out of compat.h Pierre-Clément Tosi
2022-03-16 19:23   ` Simon Glass
2022-03-16 15:39 ` [PATCH 7/9] include: Upgrade <linux/typecheck.h> Pierre-Clément Tosi
2022-03-16 19:23   ` Simon Glass
2022-03-17 11:46     ` Pierre-Clément Tosi
2022-03-28  6:35       ` Simon Glass [this message]
2022-03-16 15:39 ` [PATCH 8/9] arm64: Import <asm/sysreg.h> from Linux Pierre-Clément Tosi
2022-03-16 15:39 ` [PATCH 9/9] arm64: Import <asm/esr.h> " Pierre-Clément Tosi
2022-03-16 19:47   ` Sean Anderson
2022-03-17 17:39     ` Pierre-Clément Tosi
2022-03-22 20:39       ` Sean Anderson
2022-03-17 19:13 ` [PATCH 1/9] net: gmac_rockchip: Fix misuse of GENMASK macro Ramon Fried
2022-04-06 15:08 ` Kever Yang
2022-04-07 12:28   ` David Wu

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='CAPnjgZ04RnRbHsUXqOFH=+b-Zbc3jx0kHVMDpFAHsYwCgdx_9A@mail.gmail.com' \
    --to=sjg@chromium.org \
    --cc=ptosi@google.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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.