From: David Laight <David.Laight@ACULAB.COM>
To: 'Peter Zijlstra' <peterz@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"dan.j.williams@intel.com" <dan.j.williams@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>
Subject: RE: cleanup: Make no_free_ptr() __must_check
Date: Tue, 15 Aug 2023 15:16:26 +0000 [thread overview]
Message-ID: <4ff59df127e24b83a7c3c9d9aba17857@AcuMS.aculab.com> (raw)
In-Reply-To: <20230815135339.GA966323@hirez.programming.kicks-ass.net>
From: Peter Zijlstra
> Sent: 15 August 2023 14:54
...
> > Also, isn't it more complicated than necessary? Can we get rid of the
> > inner stmt expr and tmp var by just making it
> >
> > ((void) (p), ((typeof(p))__no_free_ptr((void **)&(p)))
> >
> > which is more or less the whole reason comma expressions is a thing.
>
> Ah, so the point of the statement expression before the comma is to
> validate that (p) is in fact a pointer, and to that effect we assign it
> to a 'void *' temporary.
>
> If that case is invalid, we'll get a compile fail with a dodgy message.
>
> I did this, because (void **)&(p) looses type integrity due to the cast.
>
> But yeah, I suppose it all needs a wee comment.
Perhaps add an is_pointer_type() along with is_signed_type()
(and really is_constexpr()) to a global header.
Various checks can be used including:
#define is_pointer_type(t) (!is_constexpr((t)0))
which gives a 0/1 to play with rather than an immediate error.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2023-08-15 15:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 10:52 Peter Zijlstra
2023-08-15 11:28 ` Rasmus Villemoes
2023-08-15 13:53 ` Peter Zijlstra
2023-08-15 15:16 ` David Laight [this message]
2023-08-16 7:23 ` Rasmus Villemoes
2023-08-16 8:00 ` Linus Torvalds
2023-08-16 8:58 ` Rasmus Villemoes
2023-08-16 9:17 ` Peter Zijlstra
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=4ff59df127e24b83a7c3c9d9aba17857@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=dan.j.williams@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=ndesaulniers@google.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®