[PATCH GnuPG 5/7] g10: check null in assert

Werner Koch wk at gnupg.org
Thu Jan 29 10:42:14 CET 2026


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 284 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20260129/a3bc3d28/attachment.sig>


More information about the Gnupg-devel mailing list