[git] GnuPG - branch, master, updated. gnupg-2.1.15-373-g4bd12b5

by Werner Koch cvs at cvs.gnupg.org
Tue Nov 15 16:31:43 CET 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  4bd12b571e661c7f208cf8a96c32bbacfc8b2598 (commit)
       via  8ea3b4c4102dc67ed83d4419b7171e422fc01047 (commit)
      from  12834e84aca9d74800245f0f2f2e6b5123e76173 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4bd12b571e661c7f208cf8a96c32bbacfc8b2598
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Nov 15 16:29:08 2016 +0100

    doc: Add comment to make clear that KBNODE is deprecated.
    
    --
    
    kbnode_t has replaced KBNODE for new code years ago, but that should
    be documented.  No bulk changes please to keep git blame easy to read.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/gpg.h b/g10/gpg.h
index 8bc4c08..3bf023b 100644
--- a/g10/gpg.h
+++ b/g10/gpg.h
@@ -60,7 +60,7 @@ struct dirmngr_local_s;
 typedef struct dirmngr_local_s *dirmngr_local_t;
 
 /* Object used to describe a keyblok node.  */
-typedef struct kbnode_struct *KBNODE;
+typedef struct kbnode_struct *KBNODE;   /* Deprecated use kbnode_t. */
 typedef struct kbnode_struct *kbnode_t;
 
 /* TOFU database meta object.  */

commit 8ea3b4c4102dc67ed83d4419b7171e422fc01047
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Nov 15 16:23:41 2016 +0100

    gpg: Use usual free semantics for packet structure free functions.
    
    * g10/free-packet.c (free_attributes): Turn function into a nop for a
    NULL arg.
    (free_user_id): Ditto.
    (free_compressed): Ditto.
    (free_encrypted): Ditto.
    (free_plaintext): Ditto.
    (release_public_key_parts): Avoid extra check for NULL.
    * g10/getkey.c (get_best_pubkey_byname): Ditto.
    --
    
    This change avoid surprises because it is common that function named
    like free and taking a pointer also have similar semantics.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/free-packet.c b/g10/free-packet.c
index 2ca1d3b..6038d26 100644
--- a/g10/free-packet.c
+++ b/g10/free-packet.c
@@ -114,11 +114,8 @@ release_public_key_parts (PKT_public_key *pk)
       xfree (pk->prefs);
       pk->prefs = NULL;
     }
-  if (pk->user_id)
-    {
-      free_user_id (pk->user_id);
-      pk->user_id = NULL;
-    }
+  free_user_id (pk->user_id);
+  pk->user_id = NULL;
   if (pk->revkey)
     {
       xfree(pk->revkey);
@@ -293,6 +290,9 @@ free_comment( PKT_comment *rem )
 void
 free_attributes(PKT_user_id *uid)
 {
+  if (!uid)
+    return;
+
   xfree(uid->attribs);
   xfree(uid->attrib_data);
 
@@ -304,70 +304,94 @@ free_attributes(PKT_user_id *uid)
 void
 free_user_id (PKT_user_id *uid)
 {
-    log_assert (uid->ref > 0);
-    if (--uid->ref)
-        return;
-
-    free_attributes(uid);
-    xfree (uid->prefs);
-    xfree (uid->namehash);
-    xfree (uid->mbox);
-    xfree (uid);
+  if (!uid)
+    return;
+
+  log_assert (uid->ref > 0);
+  if (--uid->ref)
+    return;
+
+  free_attributes(uid);
+  xfree (uid->prefs);
+  xfree (uid->namehash);
+  xfree (uid->mbox);
+  xfree (uid);
 }
 
 void
 free_compressed( PKT_compressed *zd )
 {
-    if( zd->buf ) { /* have to skip some bytes */
-	/* don't have any information about the length, so
-	 * we assume this is the last packet */
-	while( iobuf_read( zd->buf, NULL, 1<<30 ) != -1 )
-	    ;
+  if (!zd)
+    return;
+
+  if (zd->buf)
+    {
+      /* We need to skip some bytes.  Because don't have any
+       * information about the length, so we assume this is the last
+       * packet */
+      while (iobuf_read( zd->buf, NULL, 1<<30 ) != -1)
+        ;
     }
-    xfree(zd);
+  xfree(zd);
 }
 
 void
 free_encrypted( PKT_encrypted *ed )
 {
-    if( ed->buf ) { /* have to skip some bytes */
-	if( ed->is_partial ) {
-	    while( iobuf_read( ed->buf, NULL, 1<<30 ) != -1 )
-		;
+  if (!ed)
+    return;
+
+  if (ed->buf)
+    {
+      /* We need to skip some bytes. */
+      if (ed->is_partial)
+        {
+          while (iobuf_read( ed->buf, NULL, 1<<30 ) != -1)
+            ;
 	}
-	else {
-	   while( ed->len ) { /* skip the packet */
-	       int n = iobuf_read( ed->buf, NULL, ed->len );
-	       if( n == -1 )
-		   ed->len = 0;
-	       else
-		   ed->len -= n;
-	   }
+      else
+        {
+          while (ed->len)
+            {
+              /* Skip the packet. */
+              int n = iobuf_read( ed->buf, NULL, ed->len );
+              if (n == -1)
+                ed->len = 0;
+              else
+                ed->len -= n;
+            }
 	}
     }
-    xfree(ed);
+  xfree (ed);
 }
 
 
 void
 free_plaintext( PKT_plaintext *pt )
 {
-    if( pt->buf ) { /* have to skip some bytes */
-	if( pt->is_partial ) {
-	    while( iobuf_read( pt->buf, NULL, 1<<30 ) != -1 )
-		;
-	}
-	else {
-	   while( pt->len ) { /* skip the packet */
-	       int n = iobuf_read( pt->buf, NULL, pt->len );
-	       if( n == -1 )
-		   pt->len = 0;
-	       else
-		   pt->len -= n;
-	   }
+  if (!pt)
+    return;
+
+  if (pt->buf)
+    { /* We need to skip some bytes.  */
+      if (pt->is_partial)
+        {
+          while (iobuf_read( pt->buf, NULL, 1<<30 ) != -1)
+            ;
+        }
+      else
+        {
+          while( pt->len )
+            { /* Skip the packet.  */
+              int n = iobuf_read( pt->buf, NULL, pt->len );
+              if (n == -1)
+                pt->len = 0;
+              else
+                pt->len -= n;
+            }
 	}
     }
-    xfree(pt);
+  xfree (pt);
 }
 
 /****************
diff --git a/g10/getkey.c b/g10/getkey.c
index 5792302..f0e33c5 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -1602,29 +1602,25 @@ get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk,
             {
               /* New key is better.  */
               release_public_key_parts (&best.key);
-              if (best.uid)
-                free_user_id (best.uid);
+              free_user_id (best.uid);
               best = new;
             }
           else if (diff > 0)
             {
               /* Old key is better.  */
               release_public_key_parts (&new.key);
-              if (new.uid)
-                free_user_id (new.uid);
+              free_user_id (new.uid);
             }
           else
             {
               /* A tie.  Keep the old key.  */
               release_public_key_parts (&new.key);
-              if (new.uid)
-                free_user_id (new.uid);
+              free_user_id (new.uid);
             }
         }
       getkey_end (ctx);
       ctx = NULL;
-      if (best.uid)
-        free_user_id (best.uid);
+      free_user_id (best.uid);
 
       if (best.valid)
         {
@@ -3604,8 +3600,7 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact,
   if (latest_key)
     {
       pk = latest_key->pkt->pkt.public_key;
-      if (pk->user_id)
-	free_user_id (pk->user_id);
+      free_user_id (pk->user_id);
       pk->user_id = scopy_user_id (foundu);
     }
 

-----------------------------------------------------------------------

Summary of changes:
 g10/free-packet.c | 118 ++++++++++++++++++++++++++++++++----------------------
 g10/getkey.c      |  15 +++----
 g10/gpg.h         |   2 +-
 3 files changed, 77 insertions(+), 58 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list