cli: mime node: fix compiler warning when building against gmime 2.4
authorJani Nikula <jani@nikula.org>
Sat, 6 Apr 2013 11:47:43 +0000 (14:47 +0300)
committerDavid Bremner <bremner@debian.org>
Sun, 14 Apr 2013 22:49:16 +0000 (19:49 -0300)
commit d487ef9e58bcd193118f19f771d5ef3984616be5
Author: Jani Nikula <jani@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.

mime-node.c

index 851f963b7ee0e11e1a6a50d848b8f7e8a75adb4d..fd9e4a45e573fa504d331cd7f2636711f8a7d15b 100644 (file)
@@ -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");