[PATCH 3/3] crypto: Avoid explicit handling of GMimeCryptoContext in gmime 3.0

David Bremner david at tethera.net
Sat Jul 15 04:55:51 PDT 2017


Daniel Kahn Gillmor <dkg at fifthhorseman.net> writes:

> gmime 3.0 knows how to select the correct GMimeCryptoContext
> automatically, so a bunch of the code in notmuch can be dropped in
> that case.
>
> The #ifdef removal of the crypto stuff is better than #define aliasing
> in gmime-extra.h for this stuff.  When built against gmime 3.0:
>
>  * it reduces compiled code,
>  * it avoids initializing unused gpgme contexts, and
>  * it avoids compiled-time warnings about passing unnecessary
>    notmuch_cryptoctx_t*s.
>  /* Decrypt and optionally verify an encrypted mime node (GMime 2.6) */
>  static void
> -node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,
> -			 notmuch_crypto_context_t *cryptoctx)
> +node_decrypt_and_verify (mime_node_t *node, GMimeObject *part
> +#if (GMIME_MAJOR_VERSION < 3)
> +	     , notmuch_crypto_context_t *cryptoctx
> +#endif
> +    )

The amount of ifdef-ery here rises to a level that we usually try to
avoid. Overall I need some more time to think about different ways to do
this, and see if any of them are better.  I haven't coded it up yet, but
I'm think a macro that expands to unused() for gmime-3.0 might be a
cleaner solution than some of the inline ifdefs here.

d






More information about the notmuch mailing list