[svn] GnuPG - r5309 - in trunk: common kbx tools

svn author marcus cvs at cvs.gnupg.org
Tue Apr 20 03:11:36 CEST 2010


Author: marcus
Date: 2010-04-20 03:11:35 +0200 (Tue, 20 Apr 2010)
New Revision: 5309

Modified:
   trunk/common/ChangeLog
   trunk/common/logging.c
   trunk/common/pka.c
   trunk/common/signal.c
   trunk/common/sysutils.c
   trunk/common/t-exechelp.c
   trunk/kbx/ChangeLog
   trunk/kbx/keybox-update.c
   trunk/tools/ChangeLog
   trunk/tools/gpgconf-comp.c
Log:
common/
2010-04-20  Marcus Brinkmann  <marcus at g10code.de>

	* logging.c (do_log_ignore_arg): New helper function.
	(log_string): Use it to remove ugly volatile hack that causes gcc
	warning.
	(log_flush): Likewise.
	* sysutils.c (gnupg_unsetenv) [!HAVE_W32CE_SYSTEM]: Return something.
	(gnupg_setenv) [!HAVE_W32CE_SYSTEM]: Likewise.
	* pka.c (get_pka_info): Solve strict aliasing rule violation.
	* t-exechelp.c (test_close_all_fds): Use dummy variables to
	silence gcc warning.

kbx/
2010-04-20  Marcus Brinkmann  <marcus at g10code.de>

	* keybox-update.c [!HAVE_DOSISH_SYSTEM]: Include
	../common/sysutils.h even then to silence gcc warning about
	missing declaration of gnupg_remove.

tools/
2010-04-20  Marcus Brinkmann  <marcus at g10code.de>

	* gpgconf-comp.c (option_check_validity): Use dummy variables to
	silence gcc warning.


Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/common/ChangeLog	2010-04-20 01:11:35 UTC (rev 5309)
@@ -1,3 +1,15 @@
+2010-04-20  Marcus Brinkmann  <marcus at g10code.de>
+
+	* logging.c (do_log_ignore_arg): New helper function.
+	(log_string): Use it to remove ugly volatile hack that causes gcc
+	warning.
+	(log_flush): Likewise.
+	* sysutils.c (gnupg_unsetenv) [!HAVE_W32CE_SYSTEM]: Return something.
+	(gnupg_setenv) [!HAVE_W32CE_SYSTEM]: Likewise.
+	* pka.c (get_pka_info): Solve strict aliasing rule violation.
+	* t-exechelp.c (test_close_all_fds): Use dummy variables to
+	silence gcc warning.
+
 2010-04-14  Werner Koch  <wk at g10code.com>
 
 	* Makefile.am (noinst_LIBRARIES) [W32CE]: Exclude libsimple-pwquery.

Modified: trunk/kbx/ChangeLog
===================================================================
--- trunk/kbx/ChangeLog	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/kbx/ChangeLog	2010-04-20 01:11:35 UTC (rev 5309)
@@ -1,3 +1,9 @@
+2010-04-20  Marcus Brinkmann  <marcus at g10code.de>
+
+	* keybox-update.c [!HAVE_DOSISH_SYSTEM]: Include
+	../common/sysutils.h even then to silence gcc warning about
+	missing declaration of gnupg_remove.
+
 2010-03-23  Werner Koch  <wk at g10code.com>
 
 	* Makefile.am (extra_libs): New.

Modified: trunk/tools/ChangeLog
===================================================================
--- trunk/tools/ChangeLog	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/tools/ChangeLog	2010-04-20 01:11:35 UTC (rev 5309)
@@ -1,3 +1,8 @@
+2010-04-20  Marcus Brinkmann  <marcus at g10code.de>
+
+	* gpgconf-comp.c (option_check_validity): Use dummy variables to
+	silence gcc warning.
+
 2010-04-14  Werner Koch  <wk at g10code.com>
 
 	* Makefile.am (bin_PROGRAMS) [W32CE]: Exclude gpgkey2ssh.

Modified: trunk/common/logging.c
===================================================================
--- trunk/common/logging.c	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/common/logging.c	2010-04-20 01:11:35 UTC (rev 5309)
@@ -515,16 +515,23 @@
 }
 
 
+static void
+do_log_ignore_arg (int level, const char *str, ...)
+{
+  va_list arg_ptr;
+  va_start (arg_ptr, str);
+  do_logv (level, 1, str, arg_ptr);
+  va_end (arg_ptr);
+}
+
+
 void
 log_string (int level, const char *string)
 {
-  /* We need to provide a dummy arg_ptr.  volatile is needed to
-     suppress compiler warnings.  The static is required for gcc 4.4
-     because it seems that it detects that a volatile automatic
-     variable is not any good if not initialized.  */
-  static volatile va_list dummy_arg_ptr;
-
-  do_logv (level, 1, string, dummy_arg_ptr);
+  /* We need a dummy arg_ptr, but there is no portable way to create
+     one.  So we call the do_logv function through a variadic wrapper.
+     MB: Why not just use "%s"?  */
+  do_log_ignore_arg (level, string);
 }
 
 
@@ -604,8 +611,7 @@
 void
 log_flush (void)
 {
-  static volatile va_list dummy_arg_ptr;
-  do_logv (JNLIB_LOG_CONT, 1, NULL, dummy_arg_ptr);
+  do_log_ignore_arg (JNLIB_LOG_CONT, NULL);
 }
 
 

Modified: trunk/common/pka.c
===================================================================
--- trunk/common/pka.c	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/common/pka.c	2010-04-20 01:11:35 UTC (rev 5309)
@@ -180,8 +180,8 @@
   unsigned char *p, *pend;
   const char *domain;
   char *name;
+  HEADER header;
 
-
   domain = strrchr (address, '@');
   if (!domain || domain == address || !domain[1])
     return NULL; /* invalid mail address given. */
@@ -196,19 +196,25 @@
   xfree (name);
   if (anslen < sizeof(HEADER))
     return NULL; /* DNS resolver returned a too short answer. */
-  if ( (rc=((HEADER*)answer)->rcode) != NOERROR )
+
+  /* Don't despair: A good compiler should optimize this away, as
+     header is just 32 byte and constant at compile time.  It's
+     one way to comply with strict aliasing rules.  */
+  memcpy (&header, answer, sizeof (header));
+
+  if ( (rc=header.rcode) != NOERROR )
     return NULL; /* DNS resolver returned an error. */
 
   /* We assume that PACKETSZ is large enough and don't do dynmically
      expansion of the buffer. */
   if (anslen > PACKETSZ)
     return NULL; /* DNS resolver returned a too long answer */
+  
+  qdcount = ntohs (header.qdcount);
+  ancount = ntohs (header.ancount);
+  nscount = ntohs (header.nscount);
+  arcount = ntohs (header.arcount);
 
-  qdcount = ntohs (((HEADER*)answer)->qdcount);
-  ancount = ntohs (((HEADER*)answer)->ancount);
-  nscount = ntohs (((HEADER*)answer)->nscount);
-  arcount = ntohs (((HEADER*)answer)->arcount);
-
   if (!ancount)
     return NULL; /* Got no answer. */
 

Modified: trunk/common/signal.c
===================================================================
--- trunk/common/signal.c	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/common/signal.c	2010-04-20 01:11:35 UTC (rev 5309)
@@ -89,6 +89,8 @@
 static RETSIGTYPE
 got_fatal_signal (int sig)
 {
+  /* Dummy result variable to suppress gcc warning.  */
+  int res;
   const char *s;
 
   if (caught_fatal_sig)
@@ -98,14 +100,14 @@
   if (cleanup_fnc)
     cleanup_fnc ();
   /* Better don't translate these messages. */
-  write (2, "\n", 1 );
+  res = write (2, "\n", 1 );
   s = log_get_prefix (NULL);
   if (s)
-    write(2, s, strlen (s));
-  write (2, ": signal ", 9 );
+    res = write(2, s, strlen (s));
+  res = write (2, ": signal ", 9 );
   s = get_signal_name(sig);
   if (s)
-    write (2, s, strlen(s) );
+    res = write (2, s, strlen(s) );
   else
     {
       /* We are in a signal handler so we can't use any kind of printf
@@ -115,7 +117,7 @@
          things are messed up because we modify its value.  Although
          this is a bug in that system, we will protect against it.  */
       if (sig < 0 || sig >= 100000)
-        write (2, "?", 1);
+        res = write (2, "?", 1);
       else 
         {
           int i, value, any=0;
@@ -124,7 +126,7 @@
             {
               if (value >= i || ((any || i==1) && !(value/i)))
                 {
-                  write (2, "0123456789"+(value/i), 1);
+                  res = write (2, "0123456789"+(value/i), 1);
                   if ((value/i))
                     any = 1;
                   value %= i;
@@ -132,7 +134,7 @@
             }
         }
     }
-  write (2, " caught ... exiting\n", 20);
+  res = write (2, " caught ... exiting\n", 20);
   
   /* Reset action to default action and raise signal again */
   init_one_signal (sig, SIG_DFL, 0);

Modified: trunk/common/sysutils.c
===================================================================
--- trunk/common/sysutils.c	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/common/sysutils.c	2010-04-20 01:11:35 UTC (rev 5309)
@@ -604,7 +604,7 @@
   (void)overwrite;
   return 0;
 #else
-  setenv (name, value, overwrite);
+  return setenv (name, value, overwrite);
 #endif
 }
 
@@ -616,9 +616,9 @@
   return 0;
 #else
 # ifdef HAVE_UNSETENV
-  unsetenv (name);
+  return unsetenv (name);
 # else
-  putenv (name);
+  return putenv (name);
 # endif
 #endif
 }

Modified: trunk/common/t-exechelp.c
===================================================================
--- trunk/common/t-exechelp.c	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/common/t-exechelp.c	2010-04-20 01:11:35 UTC (rev 5309)
@@ -76,6 +76,7 @@
   int max_fd = get_max_fds ();
   int *array;
   int fd;
+  int dummy_fd;
   int initial_count, count, n;
 #if 0
   char buffer[100];
@@ -92,10 +93,10 @@
   free (array);
 
   /* Some dups to get more file descriptors and close one. */
-  dup (1);
-  dup (1);
+  dummy_fd = dup (1);
+  dummy_fd = dup (1);
   fd = dup (1);
-  dup (1);
+  dummy_fd = dup (1);
   close (fd);
 
   array = xget_all_open_fds ();
@@ -136,14 +137,14 @@
       int except[] = { 20, 23, 24, -1 };
 
       for (n=initial_count; n < 31; n++)
-        dup (1);
+        dummy_fd = dup (1);
       array = xget_all_open_fds ();
       if (verbose)
         print_open_fds (array);
       free (array);
       for (n=0; n < 5; n++)
         {
-          dup (1);
+          dummy_fd = dup (1);
           array = xget_all_open_fds ();
           if (verbose)
             print_open_fds (array);

Modified: trunk/kbx/keybox-update.c
===================================================================
--- trunk/kbx/keybox-update.c	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/kbx/keybox-update.c	2010-04-20 01:11:35 UTC (rev 5309)
@@ -26,9 +26,7 @@
 #include <unistd.h>
 
 #include "keybox-defs.h"
-#ifdef HAVE_DOSISH_SYSTEM
 #include "../common/sysutils.h"
-#endif
 
 #define EXTSEP_S "."
 

Modified: trunk/tools/gpgconf-comp.c
===================================================================
--- trunk/tools/gpgconf-comp.c	2010-04-14 17:56:22 UTC (rev 5308)
+++ trunk/tools/gpgconf-comp.c	2010-04-20 01:11:35 UTC (rev 5309)
@@ -2241,8 +2241,11 @@
 	}
       else if (gc_arg_type[option->arg_type].fallback == GC_ARG_TYPE_INT32)
 	{
+	  long res;
+
 	  gpg_err_set_errno (0);
-	  (void) strtol (arg, &arg, 0);
+	  res = strtol (arg, &arg, 0);
+	  (void) res;
 
 	  if (errno)
 	    gc_error (1, errno, "invalid argument for option %s",
@@ -2254,8 +2257,11 @@
 	}
       else if (gc_arg_type[option->arg_type].fallback == GC_ARG_TYPE_INT32)
 	{
+	  unsigned long res;
+
 	  gpg_err_set_errno (0);
-	  (void) strtoul (arg, &arg, 0);
+	  res = strtoul (arg, &arg, 0);
+	  (void) res;
 
 	  if (errno)
 	    gc_error (1, errno, "invalid argument for option %s",




More information about the Gnupg-commits mailing list