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/