The recently committed fingerprint series introduced some const warnings
in this patch series.  This patch cleans up the warnings by splitting
out a const and non-const in find_keys(), and reverting the first
parameter of crypt_getkeybystr() to non-const.

-Kevin
# HG changeset patch
# User Kevin McCarthy <[email protected]>
# Date 1425680242 28800
#      Fri Mar 06 14:17:22 2015 -0800
# Node ID 871615f7a7a023a73b90ebd2e44a266066ba0dd0
# Parent  4c50c77cd1a2b6920a925a5336dbd7292ccf3e2f
Fix const errors caused by find_keys() changes.

Part 4 of the oppenc series changed the keyID type to const as part
of some cleanup changes.  At the time, that only propagated to
crypt_getkeybystr(), but with the fingerprint changes, this is starting
to propagate too far.

Create a separate non-const variable to deal with the crypt hook value
and revert crypt_getkeybystr()'s parameter to non-const.

diff --git a/crypt-gpgme.c b/crypt-gpgme.c
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -4201,17 +4201,17 @@
     }
   else 
     k = NULL;
   
   return k;
 }
 
 
-static crypt_key_t *crypt_getkeybystr (const char *p, short abilities,
+static crypt_key_t *crypt_getkeybystr (char *p, short abilities,
                                       unsigned int app, int *forced_valid)
 {
   LIST *hints = NULL;
   crypt_key_t *keys;
   crypt_key_t *matches = NULL;
   crypt_key_t **matches_endp = &matches;
   crypt_key_t *k;
   const char *ps, *pl, *pfcopy, *phint;
@@ -4331,16 +4331,17 @@
 }
 
 /* This routine attempts to find the keyids of the recipients of a
    message.  It returns NULL if any of the keys can not be found.
    If oppenc_mode is true, only keys that can be determined without
    prompting will be used.  */
 static char *find_keys (ADDRESS *adrlist, unsigned int app, int oppenc_mode)
 {
+  char *crypt_hook_val = NULL;
   const char *keyID = NULL;
   char *keylist = NULL, *t;
   size_t keylist_size = 0;
   size_t keylist_used = 0;
   ADDRESS *addr = NULL;
   ADDRESS *p, *q;
   crypt_key_t *k_info;
   const char *fqdn = mutt_fqdn (1);
@@ -4352,49 +4353,50 @@
   for (p = adrlist; p ; p = p->next)
     {
       char buf[LONG_STRING];
       int forced_valid = 0;
       
       q = p;
       k_info = NULL;
       
-      if ((keyID = mutt_crypt_hook (p)) != NULL)
+      if ((crypt_hook_val = mutt_crypt_hook (p)) != NULL)
         {
           int r = M_NO;
           if (! oppenc_mode)
             {
               snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"),
-                        keyID, p->mailbox);
+                        crypt_hook_val, p->mailbox);
               r = mutt_yesorno (buf, M_YES);
             }
           if (oppenc_mode || (r == M_YES))
             {
-              if (crypt_is_numerical_keyid (keyID))
+              if (crypt_is_numerical_keyid (crypt_hook_val))
                 {
+                  keyID = crypt_hook_val;
                   if (strncmp (keyID, "0x", 2) == 0)
                     keyID += 2;
                   goto bypass_selection;                /* you don't see this. 
*/
                 }
 
               /* check for e-mail address */
-              if ((t = strchr (keyID, '@')) && 
-                  (addr = rfc822_parse_adrlist (NULL, keyID)))
+              if ((t = strchr (crypt_hook_val, '@')) && 
+                  (addr = rfc822_parse_adrlist (NULL, crypt_hook_val)))
                 {
                   if (fqdn)
                     rfc822_qualify (addr, fqdn);
                   q = addr;
                 }
               else if (! oppenc_mode)
                {
 #if 0            
-                 k_info = crypt_getkeybystr (keyID, KEYFLAG_CANENCRYPT, 
+                 k_info = crypt_getkeybystr (crypt_hook_val, 
KEYFLAG_CANENCRYPT, 
                                              *r_application, &forced_valid);
 #else
-                 k_info = crypt_getkeybystr (keyID, KEYFLAG_CANENCRYPT, 
+                 k_info = crypt_getkeybystr (crypt_hook_val, 
KEYFLAG_CANENCRYPT, 
                                              app, &forced_valid);
 #endif
                }
             }
           else if (r == -1)
             {
               FREE (&keylist);
               rfc822_free_address (&addr);

Attachment: signature.asc
Description: PGP signature

Reply via email to