Re: [PATCH GnuPG 5/7] g10: check null in assert
Werner Koch via Gnupg-devel <[email protected]> Thu, 29 Jan 2026 10:42:14 +0100
| Newsgroups | gmane.comp.encryption.gpg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 28 Jan 2026 20:59, Jacob Bachmeyer said:
> NULL? Perhaps a better solution would be to change the "if (err)" to
> "if (err || !keyblock)" or the more verbose "if (err != 0 || keyblock
In this case you may have ERR == 0 and need to make sure that ERR is
set.
> shortcoming in the analyzer: does log_assert crash the program on an
> assertion failure? Does the analyzer know that? If not, a NULL
This is the macro:
# ifdef GPGRT_HAVE_MACRO_FUNCTION
# define log_assert(expr) \
((expr) \
? (void) 0 \
: _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
and this is the prototype:
void _gpgrt_log_assert (const char *expr, const char *file, int line,
const char *func) GPGRT_ATTR_NORETURN;
with:
/* The noreturn attribute. */
#if _GPG_ERR_GCC_VERSION >= 20500
# define GPGRT_ATTR_NORETURN __attribute__ ((__noreturn__))
#else
# define GPGRT_ATTR_NORETURN
#endif
So gcc should be able to know this.
Shalom-Salam,
Werner
--
The pioneers of a warless world are the youth that
refuse military service. - A. Einstein
_______________________________________________
Gnupg-devel mailing list
[email protected]
https://lists.gnupg.org/mailman/listinfo/gnupg-devel
openpgp-digital-signature.asc
(application/pgp-signature, 284 B)
-----BEGIN PGP SIGNATURE----- iJ8EARYKAEcWIQSHd0YfKgdOvEgNNZQZzByeCFsQegUCaXsrdxsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMSwyLDINHHdrQGdudXBnLm9yZwAKCRAZzByeCFsQelcxAP9F l+mCCHcCqPKck29WkvafVktF01KJIOOcCDeXGYvtBQEAgdbB7HOhTgGWE3LuPTBU 3yLlc5YQHaUasQDjYpgPSww= =gwv4 -----END PGP SIGNATURE-----