[Pkg-gnupg-commit] [gnupg2] 41/241: gpg: Factor out code into a standalone function.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Dec 9 20:31:51 UTC 2015


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

dkg pushed a commit to branch master
in repository gnupg2.

commit 243f90afba87e99ca42e2451ac5cc59d00a044ac
Author: Neal H. Walfield <neal at g10code.com>
Date:   Wed Oct 21 12:52:56 2015 +0200

    gpg: Factor out code into a standalone function.
    
    * g10/trustdb.c (tdb_keyid_is_utk): New function.
    (add_utk): Use it.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>
---
 g10/trustdb.c | 21 ++++++++++++++-------
 g10/trustdb.h |  2 ++
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/g10/trustdb.c b/g10/trustdb.c
index cadc7e9..1be98b5 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -229,13 +229,8 @@ add_utk (u32 *kid)
 {
   struct key_item *k;
 
-  for (k = utk_list; k; k = k->next)
-    {
-      if (k->kid[0] == kid[0] && k->kid[1] == kid[1])
-        {
-          return 0;
-        }
-    }
+  if (tdb_keyid_is_utk (kid))
+    return 0;
 
   k = new_key_item ();
   k->kid[0] = kid[0];
@@ -317,6 +312,18 @@ verify_own_keys(void)
   return;
 }
 
+/* Returns whether KID is on the list of ultimately trusted keys.  */
+int
+tdb_keyid_is_utk (u32 *kid)
+{
+  struct key_item *k;
+
+  for (k = utk_list; k; k = k->next)
+    if (k->kid[0] == kid[0] && k->kid[1] == kid[1])
+      return 1;
+
+  return 0;
+}
 

 /*********************************************
  *********** TrustDB stuff *******************
diff --git a/g10/trustdb.h b/g10/trustdb.h
index adb75d7..718f779 100644
--- a/g10/trustdb.h
+++ b/g10/trustdb.h
@@ -111,6 +111,8 @@ void clean_key (kbnode_t keyblock, int noisy, int self_only,
 /*-- trustdb.c --*/
 void tdb_register_trusted_keyid (u32 *keyid);
 void tdb_register_trusted_key (const char *string);
+/* Returns whether KID is on the list of ultimately trusted keys.  */
+int tdb_keyid_is_utk (u32 *kid);
 void check_trustdb (void);
 void update_trustdb (void);
 int setup_trustdb( int level, const char *dbname );

-- 
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