From d2c881867ea4858f4a4785af5ec5d4223e5e0257 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sat, 6 Apr 2013 14:47:43 +0300 Subject: [PATCH] cli: mime node: fix compiler warning when building against gmime 2.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit d487ef9e58bcd193118f19f771d5ef3984616be5 Author: Jani Nikula 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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mime-node.c b/mime-node.c index 851f963b..fd9e4a45 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");