From: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: gcc@gcc.gnu.org, cfe-dev@lists.llvm.org
Subject: Re: ISO C3X proposal: nonnull qualifier
Date: Thu, 2 Dec 2021 21:31:42 +0100 [thread overview]
Message-ID: <03338dbf-878d-2910-c676-b0945a61a10d@gmail.com> (raw)
In-Reply-To: <3178a917-e9df-36eb-4382-f8aec7b678a2@gmail.com>
On 12/2/21 21:24, Alejandro Colomar (man-pages) wrote:
>
> #define nonnull_assign(nn, p) \
> ({ \
> auto p_ = p; \
> auto nn_ = nn; \
> \
> if (p_ == NULL) \
> *nn_ = const_cast(typeof(nn_), p_); \
D'oh, this check should be the opposite, of course :)
> \
> p_ == NULL; \
> })
>
And I forgot to mention, that this macro intentionally leaves the
nonnull pointer (nn) uninitialized in the case of a NULL input pointer
(p), so that the compiler can then warn about an uninitialized variable
if it's used uninitialized.
Cheers,
Alex
--
Alejandro Colomar
Linux man-pages comaintainer; http://www.kernel.org/doc/man-pages/
next prev parent reply other threads:[~2021-12-02 20:31 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 16:01 Alejandro Colomar (man-pages)
2021-11-15 16:30 ` Alejandro Colomar (man-pages)
2021-11-15 20:18 ` Joseph Myers
2021-11-15 21:09 ` Alejandro Colomar (man-pages)
2021-11-15 22:17 ` Joseph Myers
2021-11-15 22:35 ` Alejandro Colomar (man-pages)
2021-11-15 22:47 ` Joseph Myers
2021-11-16 12:34 ` Alejandro Colomar (man-pages)
2021-11-17 0:06 ` Alejandro Colomar (man-pages)
2021-11-20 16:47 ` Ping: " Alejandro Colomar (man-pages)
2021-11-23 11:32 ` [cfe-dev] " Dmitri Gribenko
2021-11-23 11:17 ` Dmitri Gribenko
2021-11-23 11:45 ` Alejandro Colomar (man-pages)
2021-11-23 12:45 ` Dmitri Gribenko
2021-12-01 22:24 ` Alejandro Colomar (man-pages)
2021-12-02 0:39 ` Dmitri Gribenko
2021-12-02 1:00 ` Alejandro Colomar (man-pages)
2021-12-02 20:24 ` Alejandro Colomar (man-pages)
2021-12-02 20:31 ` Alejandro Colomar (man-pages) [this message]
2021-12-02 20:36 ` Joseph Myers
2021-11-16 9:30 ` Jonathan Wakely
2021-11-16 17:13 ` [cfe-dev] " Arthur O'Dwyer
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=03338dbf-878d-2910-c676-b0945a61a10d@gmail.com \
--to=alx.manpages@gmail.com \
--cc=cfe-dev@lists.llvm.org \
--cc=gcc@gcc.gnu.org \
--cc=joseph@codesourcery.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).