[Pkg-gnupg-commit] [gnupg2] 236/292: sm: Remove unused arg SECRET from keydb functions.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit c8044c6e335f044d7386b9e8869bc4a0d3adff70
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Nov 10 15:38:14 2016 +0100

    sm: Remove unused arg SECRET from keydb functions.
    
    * sm/keydb.c (struct resource_item): Remove field 'secret'.
    (keydb_add_resource): Remove arg 'secret' and change all callers.
    (keydb_new): Ditto.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 sm/call-dirmngr.c |  2 +-
 sm/certchain.c    |  6 +++---
 sm/certlist.c     |  4 ++--
 sm/decrypt.c      |  2 +-
 sm/delete.c       |  2 +-
 sm/encrypt.c      |  2 +-
 sm/export.c       |  5 ++---
 sm/gpgsm.c        |  4 ++--
 sm/import.c       |  2 +-
 sm/keydb.c        | 29 ++++++++++-------------------
 sm/keydb.h        |  5 ++---
 sm/keylist.c      |  2 +-
 sm/sign.c         |  6 +++---
 sm/verify.c       |  2 +-
 14 files changed, 31 insertions(+), 42 deletions(-)

diff --git a/sm/call-dirmngr.c b/sm/call-dirmngr.c
index ea1bb5f..dd56641 100644
--- a/sm/call-dirmngr.c
+++ b/sm/call-dirmngr.c
@@ -576,7 +576,7 @@ gpgsm_dirmngr_isvalid (ctrl_t ctrl,
                  from the dirmngr.  Try our own cert store now.  */
               KEYDB_HANDLE kh;
 
-              kh = keydb_new (0);
+              kh = keydb_new ();
               if (!kh)
                 rc = gpg_error (GPG_ERR_ENOMEM);
               if (!rc)
diff --git a/sm/certchain.c b/sm/certchain.c
index feefbb7..1ac7228 100644
--- a/sm/certchain.c
+++ b/sm/certchain.c
@@ -807,7 +807,7 @@ gpgsm_walk_cert_chain (ctrl_t ctrl, ksba_cert_t start, ksba_cert_t *r_next)
   int rc = 0;
   char *issuer = NULL;
   char *subject = NULL;
-  KEYDB_HANDLE kh = keydb_new (0);
+  KEYDB_HANDLE kh = keydb_new ();
 
   *r_next = NULL;
   if (!kh)
@@ -1303,7 +1303,7 @@ do_validate_chain (ctrl_t ctrl, ksba_cert_t cert, ksba_isotime_t checktime_arg,
       return 0;
     }
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       log_error (_("failed to allocate keyDB handle\n"));
@@ -1941,7 +1941,7 @@ gpgsm_basic_cert_check (ctrl_t ctrl, ksba_cert_t cert)
       return 0;
     }
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       log_error (_("failed to allocate keyDB handle\n"));
diff --git a/sm/certlist.c b/sm/certlist.c
index 616f4f1..a041a75 100644
--- a/sm/certlist.c
+++ b/sm/certlist.c
@@ -319,7 +319,7 @@ gpgsm_add_to_certlist (ctrl_t ctrl, const char *name, int secret,
   rc = classify_user_id (name, &desc, 0);
   if (!rc)
     {
-      kh = keydb_new (0);
+      kh = keydb_new ();
       if (!kh)
         rc = gpg_error (GPG_ERR_ENOMEM);
       else
@@ -498,7 +498,7 @@ gpgsm_find_cert (const char *name, ksba_sexp_t keyid, ksba_cert_t *r_cert)
   rc = classify_user_id (name, &desc, 0);
   if (!rc)
     {
-      kh = keydb_new (0);
+      kh = keydb_new ();
       if (!kh)
         rc = gpg_error (GPG_ERR_ENOMEM);
       else
diff --git a/sm/decrypt.c b/sm/decrypt.c
index 3cee54b..9ae87d8 100644
--- a/sm/decrypt.c
+++ b/sm/decrypt.c
@@ -256,7 +256,7 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
 
   audit_set_type (ctrl->audit, AUDIT_TYPE_DECRYPT);
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       log_error (_("failed to allocate keyDB handle\n"));
diff --git a/sm/delete.c b/sm/delete.c
index e8638c3..ae06261 100644
--- a/sm/delete.c
+++ b/sm/delete.c
@@ -54,7 +54,7 @@ delete_one (ctrl_t ctrl, const char *username)
       goto leave;
     }
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       log_error ("keydb_new failed\n");
diff --git a/sm/encrypt.c b/sm/encrypt.c
index 8555f4a..2c664f8 100644
--- a/sm/encrypt.c
+++ b/sm/encrypt.c
@@ -336,7 +336,7 @@ gpgsm_encrypt (ctrl_t ctrl, certlist_t recplist, int data_fd, estream_t out_fp)
     count++;
   audit_log_i (ctrl->audit, AUDIT_GOT_RECIPIENTS, count);
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       log_error (_("failed to allocate keyDB handle\n"));
diff --git a/sm/export.c b/sm/export.c
index 1317945..4fedfa2 100644
--- a/sm/export.c
+++ b/sm/export.c
@@ -150,7 +150,7 @@ gpgsm_export (ctrl_t ctrl, strlist_t names, estream_t stream)
       goto leave;
     }
 
-  hd = keydb_new (0);
+  hd = keydb_new ();
   if (!hd)
     {
       log_error ("keydb_new failed\n");
@@ -338,8 +338,7 @@ gpgsm_p12_export (ctrl_t ctrl, const char *name, estream_t stream, int rawmode)
   void *data;
   size_t datalen;
 
-
-  hd = keydb_new (0);
+  hd = keydb_new ();
   if (!hd)
     {
       log_error ("keydb_new failed\n");
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index 6c9d85c..ae447ee 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -1616,7 +1616,7 @@ main ( int argc, char **argv)
     {
       int created;
 
-      keydb_add_resource ("pubring.kbx", 0, 0, &created);
+      keydb_add_resource ("pubring.kbx", 0, &created);
       if (created && !no_common_certs_import)
         {
           /* Import the standard certificates for a new default keybox. */
@@ -1634,7 +1634,7 @@ main ( int argc, char **argv)
         }
     }
   for (sl = nrings; sl; sl = sl->next)
-    keydb_add_resource (sl->d, 0, 0, NULL);
+    keydb_add_resource (sl->d, 0, NULL);
   FREE_STRLIST(nrings);
 
 
diff --git a/sm/import.c b/sm/import.c
index 2011fb5..bd1af27 100644
--- a/sm/import.c
+++ b/sm/import.c
@@ -403,7 +403,7 @@ reimport_one (ctrl_t ctrl, struct stats_s *stats, int in_fd)
   ksba_cert_t cert = NULL;
   unsigned int flags;
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       err = gpg_error (GPG_ERR_ENOMEM);;
diff --git a/sm/keydb.c b/sm/keydb.c
index 02ca5ad..64b06e7 100644
--- a/sm/keydb.c
+++ b/sm/keydb.c
@@ -47,7 +47,6 @@ struct resource_item {
     KEYBOX_HANDLE kr;
   } u;
   void *token;
-  int secret;
   dotlock_t lockhandle;
 };
 
@@ -250,9 +249,9 @@ maybe_create_keybox (char *filename, int force, int *r_created)
  * if the function has created a new keybox.
  */
 gpg_error_t
-keydb_add_resource (const char *url, int force, int secret, int *auto_created)
+keydb_add_resource (const char *url, int force, int *auto_created)
 {
-  static int any_secret, any_public;
+  static int any_public;
   const char *resname = url;
   char *filename = NULL;
   gpg_error_t err = 0;
@@ -293,7 +292,7 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
     filename = xstrdup (resname);
 
   if (!force)
-    force = secret? !any_secret : !any_public;
+    force = !any_public;
 
   /* see whether we can determine the filetype */
   if (rt == KEYDB_RESOURCE_TYPE_NONE)
@@ -335,7 +334,7 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
       {
         void *token;
 
-        err = keybox_register_file (filename, secret, &token);
+        err = keybox_register_file (filename, 0, &token);
         if (gpg_err_code (err) == GPG_ERR_EEXIST)
           ; /* Already registered - ignore.  */
         else if (err)
@@ -347,7 +346,6 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
             all_resources[used_resources].type = rt;
             all_resources[used_resources].u.kr = NULL; /* Not used here */
             all_resources[used_resources].token = token;
-            all_resources[used_resources].secret = secret;
 
             all_resources[used_resources].lockhandle
               = dotlock_create (filename, 0);
@@ -357,7 +355,7 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
             /* Do a compress run if needed and the file is not locked. */
             if (!dotlock_take (all_resources[used_resources].lockhandle, 0))
               {
-                KEYBOX_HANDLE kbxhd = keybox_new_x509 (token, secret);
+                KEYBOX_HANDLE kbxhd = keybox_new_x509 (token, 0);
 
                 if (kbxhd)
                   {
@@ -383,8 +381,6 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
  leave:
   if (err)
     log_error ("keyblock resource '%s': %s\n", filename, gpg_strerror (err));
-  else if (secret)
-    any_secret = 1;
   else
     any_public = 1;
   xfree (filename);
@@ -393,7 +389,7 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
 
 
 KEYDB_HANDLE
-keydb_new (int secret)
+keydb_new (void)
 {
   KEYDB_HANDLE hd;
   int i, j;
@@ -405,8 +401,6 @@ keydb_new (int secret)
   assert (used_resources <= MAX_KEYDB_RESOURCES);
   for (i=j=0; i < used_resources; i++)
     {
-      if (!all_resources[i].secret != !secret)
-        continue;
       switch (all_resources[i].type)
         {
         case KEYDB_RESOURCE_TYPE_NONE: /* ignore */
@@ -414,9 +408,8 @@ keydb_new (int secret)
         case KEYDB_RESOURCE_TYPE_KEYBOX:
           hd->active[j].type   = all_resources[i].type;
           hd->active[j].token  = all_resources[i].token;
-          hd->active[j].secret = all_resources[i].secret;
           hd->active[j].lockhandle = all_resources[i].lockhandle;
-          hd->active[j].u.kr = keybox_new_x509 (all_resources[i].token, secret);
+          hd->active[j].u.kr = keybox_new_x509 (all_resources[i].token, 0);
           if (!hd->active[j].u.kr)
             {
               xfree (hd);
@@ -919,8 +912,6 @@ keydb_rebuild_caches (void)
 
   for (i=0; i < used_resources; i++)
     {
-      if (all_resources[i].secret)
-        continue;
       switch (all_resources[i].type)
         {
         case KEYDB_RESOURCE_TYPE_NONE: /* ignore */
@@ -1121,7 +1112,7 @@ keydb_store_cert (ksba_cert_t cert, int ephemeral, int *existed)
       return gpg_error (GPG_ERR_GENERAL);
     }
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       log_error (_("failed to allocate keyDB handle\n"));
@@ -1207,7 +1198,7 @@ keydb_set_cert_flags (ksba_cert_t cert, int ephemeral,
       return gpg_error (GPG_ERR_GENERAL);
     }
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       log_error (_("failed to allocate keyDB handle\n"));
@@ -1278,7 +1269,7 @@ keydb_clear_some_cert_flags (ctrl_t ctrl, strlist_t names)
 
   (void)ctrl;
 
-  hd = keydb_new (0);
+  hd = keydb_new ();
   if (!hd)
     {
       log_error ("keydb_new failed\n");
diff --git a/sm/keydb.h b/sm/keydb.h
index 5713fde..bdf4a2d 100644
--- a/sm/keydb.h
+++ b/sm/keydb.h
@@ -31,9 +31,8 @@ typedef struct keydb_handle *KEYDB_HANDLE;
 
 
 /*-- keydb.c --*/
-gpg_error_t keydb_add_resource (const char *url, int force, int secret,
-                                int *auto_created);
-KEYDB_HANDLE keydb_new (int secret);
+gpg_error_t keydb_add_resource (const char *url, int force, int *auto_created);
+KEYDB_HANDLE keydb_new (void);
 void keydb_release (KEYDB_HANDLE hd);
 int keydb_set_ephemeral (KEYDB_HANDLE hd, int yes);
 const char *keydb_get_resource_name (KEYDB_HANDLE hd);
diff --git a/sm/keylist.c b/sm/keylist.c
index c4d475c..7bd20dd 100644
--- a/sm/keylist.c
+++ b/sm/keylist.c
@@ -1329,7 +1329,7 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
   int have_secret;
   int want_ephemeral = ctrl->with_ephemeral_keys;
 
-  hd = keydb_new (0);
+  hd = keydb_new ();
   if (!hd)
     {
       log_error ("keydb_new failed\n");
diff --git a/sm/sign.c b/sm/sign.c
index 6eec2e9..ff7215f 100644
--- a/sm/sign.c
+++ b/sm/sign.c
@@ -141,7 +141,7 @@ gpgsm_get_default_cert (ctrl_t ctrl, ksba_cert_t *r_cert)
   int rc;
   char *p;
 
-  hd = keydb_new (0);
+  hd = keydb_new ();
   if (!hd)
     return gpg_error (GPG_ERR_GENERAL);
   rc = keydb_search_first (hd);
@@ -218,7 +218,7 @@ get_default_signer (ctrl_t ctrl)
       return NULL;
     }
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     return NULL;
 
@@ -331,7 +331,7 @@ gpgsm_sign (ctrl_t ctrl, certlist_t signerlist,
 
   audit_set_type (ctrl->audit, AUDIT_TYPE_SIGN);
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       log_error (_("failed to allocate keyDB handle\n"));
diff --git a/sm/verify.c b/sm/verify.c
index 4df1cc0..7a9f7e1 100644
--- a/sm/verify.c
+++ b/sm/verify.c
@@ -108,7 +108,7 @@ gpgsm_verify (ctrl_t ctrl, int in_fd, int data_fd, estream_t out_fp)
 
   audit_set_type (ctrl->audit, AUDIT_TYPE_VERIFY);
 
-  kh = keydb_new (0);
+  kh = keydb_new ();
   if (!kh)
     {
       log_error (_("failed to allocate keyDB handle\n"));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list