[PATCH] cli: mime node: fix compiler warning when building against gmime 2.4

Mark Walters markwalters1009 at gmail.com
Thu Apr 11 23:12:45 PDT 2013


On Sat, 06 Apr 2013, Jani Nikula <jani at nikula.org> wrote:
> commit d487ef9e58bcd193118f19f771d5ef3984616be5
> Author: Jani Nikula <jani at nikula.org>
> Date:   Sat Mar 30 15:53:16 2013 +0200
>
>     cli: mime node: abstract decryption and signature verification
>
> introduced a compiler warning, reported by Mark Walters, when building
> against gmime 2.4:
>
> mime-node.c:224:9: warning: assignment discards ‘const’ qualifier from
> pointer target type [enabled by default]
>
> Pass the non-const signature validity to the destructor to fix this.
>
> ---
>
> Not even compile tested as I don't have gmime 2.4 on any
> systems... Mark, please build and run the tests with this. Thanks.

This fixes the build warning and all tests pass. Thanks!

Mark

> ---
>  mime-node.c |   13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/mime-node.c b/mime-node.c
> index 851f963..fd9e4a4 100644
> --- a/mime-node.c
> +++ b/mime-node.c
> @@ -217,11 +217,12 @@ _signature_validity_free (GMimeSignatureValidity **proxy)
>  
>  /* Set up signature validity destructor (GMime 2.4) */
>  static void
> -set_signature_validity_destructor (mime_node_t *node)
> +set_signature_validity_destructor (mime_node_t *node,
> +				   GMimeSignatureValidity *sig_validity)
>  {
>      GMimeSignatureValidity **proxy = talloc (node, GMimeSignatureValidity *);
>      if (proxy) {
> -	*proxy = node->sig_validity;
> +	*proxy = sig_validity;
>  	talloc_set_destructor (proxy, _signature_validity_free);
>      }
>  }
> @@ -232,12 +233,14 @@ node_verify (mime_node_t *node, GMimeObject *part,
>  	     notmuch_crypto_context_t *cryptoctx)
>  {
>      GError *err = NULL;
> +    GMimeSignatureValidity *sig_validity;
>  
>      node->verify_attempted = TRUE;
> -    node->sig_validity = g_mime_multipart_signed_verify
> +    sig_validity = g_mime_multipart_signed_verify
>  	(GMIME_MULTIPART_SIGNED (part), cryptoctx, &err);
> -    if (node->sig_validity) {
> -	set_signature_validity_destructor (node);
> +    node->sig_validity = sig_validity;
> +    if (sig_validity) {
> +	set_signature_validity_destructor (node, sig_validity);
>      } else {
>  	fprintf (stderr, "Failed to verify signed part: %s\n",
>  		 err ? err->message : "no error explanation given");
> -- 
> 1.7.10.4


More information about the notmuch mailing list