[git] Assuan - branch, master, updated. libassuan-2.1.1-7-g134c045

by Werner Koch cvs at cvs.gnupg.org
Mon Jun 30 10:14:40 CEST 2014


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 "IPC library used by GnuPG".

The branch, master has been updated
       via  134c045c7d1f93ce61f62193d33af8a6e8825543 (commit)
      from  326a2918d645dd3d38dbc928e4452c66cb9757f1 (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 134c045c7d1f93ce61f62193d33af8a6e8825543
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jun 25 20:25:28 2014 +0200

    Avoid a vasprintf call if tracing has not been enabled.
    
    * src/debug.c (_assuan_debug): Check wether CAT want to be logged.

diff --git a/src/debug.c b/src/debug.c
index 5ed4d4d..d6c3e80 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -1,22 +1,22 @@
 /* debug.c - helpful output in desperate situations
    Copyright (C) 2000 Werner Koch (dd9jn)
    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 g10 Code GmbH
- 
+
    This file is part of Assuan.
 
    Assuan is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.
-   
+
    Assuan is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
-   
+
    You should have received a copy of the GNU Lesser General Public
    License along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
 #if HAVE_CONFIG_H
@@ -51,7 +51,11 @@ _assuan_debug (assuan_context_t ctx, unsigned int cat, const char *format, ...)
   char *msg;
   int res;
 
-  if (!ctx || !ctx->log_cb)
+  /* vasprintf is an expensive operation thus we first check whether
+     the callback has enabled CAT for logging.  */
+  if (!ctx
+      || !ctx->log_cb
+      || !(*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL))
     return;
 
   saved_errno = errno;
@@ -77,11 +81,11 @@ _assuan_debug_begin (assuan_context_t ctx,
 
   *line = NULL;
   /* Probe if this wants to be logged based on category.  */
-  if (! ctx 
-      || ! ctx->log_cb 
+  if (! ctx
+      || ! ctx->log_cb
       || ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL))
     return;
-  
+
   va_start (arg_ptr, format);
   res = vasprintf ((char **) line, format, arg_ptr);
   va_end (arg_ptr);
@@ -147,8 +151,8 @@ _assuan_debug_buffer (assuan_context_t ctx, unsigned int cat,
   int j;
 
   /* Probe if this wants to be logged based on category.  */
-  if (!ctx 
-      || ! ctx->log_cb 
+  if (!ctx
+      || ! ctx->log_cb
       || ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL))
     return;
 
@@ -157,7 +161,7 @@ _assuan_debug_buffer (assuan_context_t ctx, unsigned int cat,
       char str[51];
       char *strp = str;
       char *strp2 = &str[34];
-      
+
       for (j = 0; j < 16; j++)
 	{
 	  unsigned char val;
@@ -179,7 +183,7 @@ _assuan_debug_buffer (assuan_context_t ctx, unsigned int cat,
       *(strp++) = ' ';
       *(strp2++) = '\n';
       *(strp2) = '\0';
-      
+
       _assuan_debug (ctx, cat, fmt, func, tagname, tag, str);
     }
 }

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

Summary of changes:
 src/debug.c |   28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
IPC library used by GnuPG
http://git.gnupg.org




More information about the Gnupg-commits mailing list