[svn] gpgme - r1461 - in trunk: . src

svn author marcus cvs at cvs.gnupg.org
Thu May 6 15:40:29 CEST 2010


Author: marcus
Date: 2010-05-06 15:39:55 +0200 (Thu, 06 May 2010)
New Revision: 1461

Modified:
   trunk/ChangeLog
   trunk/README
   trunk/configure.ac
   trunk/src/assuan-support.c
   trunk/src/conversion.c
   trunk/src/data-compat.c
   trunk/src/data-mem.c
   trunk/src/data-user.c
   trunk/src/data.c
   trunk/src/debug.c
   trunk/src/decrypt.c
   trunk/src/delete.c
   trunk/src/engine-gpgsm.c
   trunk/src/gpgme-tool.c
   trunk/src/import.c
   trunk/src/op-support.c
   trunk/src/setenv.c
   trunk/src/sign.c
   trunk/src/verify.c
   trunk/src/w32-io.c
   trunk/src/w32-util.c
Log:
2010-05-06  Marcus Brinkmann  <marcus at g10code.de>

	* configure.ac: Require libgpg-error 1.8.

src/
2010-05-06  Marcus Brinkmann  <marcus at g10code.de>

	* sign.c, data-user.c, conversion.c, debug.c, verify.c, data.c,
	decrypt.c, delete.c, assuan-support.c, import.c, engine-gpgsm.c,
	data-mem.c, op-support.c, w32-io.c, w32-util.c, data-compat.c: Use
	gpg_error_from_syserror instead gpg_error_from_errno, and use
	gpg_err_set_errno to set error number.
	* setenv.c: Include <gpg-error.h> and define __set_errno to use
	gpg_err_set_errno.
	* gpgme-tool.c (ARGP_ERR_UNKNOWN): Define to EDEADLOCK (which is
	mapped in Windows CE) instead of E2BIG (which is not).
	(gt_import_keys): Initialize err.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/ChangeLog	2010-05-06 13:39:55 UTC (rev 1461)
@@ -1,3 +1,7 @@
+2010-05-06  Marcus Brinkmann  <marcus at g10code.de>
+
+	* configure.ac: Require libgpg-error 1.8.
+
 2010-03-15  Werner Koch  <wk at g10code.com>
 
 	* configure.ac (emacs_local_vars_begin)

Modified: trunk/README
===================================================================
--- trunk/README	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/README	2010-05-06 13:39:55 UTC (rev 1461)
@@ -41,7 +41,7 @@
 Don't skip it - this is an important step!
 
 To build GPGME, you need to install libgpg-error.  You need at least
-libgpg-error 0.5.
+libgpg-error 1.8.
 
 For support of the OpenPGP protocol (default), you should use the
 latest version of GnuPG 1.2 or 1.4, available at:

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/configure.ac	2010-05-06 13:39:55 UTC (rev 1461)
@@ -283,7 +283,7 @@
 fi
 
 # Checking for libgpg-error.
-AM_PATH_GPG_ERROR(1.4,, AC_MSG_ERROR([libgpg-error was not found]))
+AM_PATH_GPG_ERROR(1.8,, AC_MSG_ERROR([libgpg-error was not found]))
 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
           [The default error source for GPGME.])
 

Modified: trunk/src/assuan-support.c
===================================================================
--- trunk/src/assuan-support.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/assuan-support.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -77,7 +77,7 @@
 	    int flags)
 {
 #ifdef HAVE_W32_SYSTEM
-  errno = ENOSYS;
+  gpg_err_set_errno (ENOSYS);
   return -1;
 #else
   return _gpgme_io_recvmsg (fd, msg, flags);
@@ -91,7 +91,7 @@
 	    int flags)
 {
 #ifdef HAVE_W32_SYSTEM
-  errno = ENOSYS;
+  gpg_err_set_errno (ENOSYS);
   return -1;
 #else
   return _gpgme_io_sendmsg (fd, msg, flags);
@@ -118,7 +118,7 @@
 
   if (! name)
     {
-      errno = ENOSYS;
+      gpg_err_set_errno (ENOSYS);
       return -1;
     }
 
@@ -203,7 +203,7 @@
 	       int protocol, assuan_fd_t filedes[2])
 {
 #ifdef HAVE_W32_SYSTEM
-  errno = ENOSYS;
+  gpg_err_set_errno (ENOSYS);
   return -1;
 #else
   /* FIXME: Debug output missing.  */

Modified: trunk/src/conversion.c
===================================================================
--- trunk/src/conversion.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/conversion.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -93,7 +93,7 @@
 	 string.  */
       dest = malloc (strlen (src) + 1);
       if (!dest)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
 
       *destp = dest;
     }
@@ -198,7 +198,7 @@
 	 string.  */
       dest = malloc (strlen (src) + 1);
       if (!dest)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
 
       *destp = dest;
     }
@@ -291,7 +291,7 @@
 	 string.  */
       dest = malloc (destlen);
       if (!dest)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
 
       *destp = dest;
     }

Modified: trunk/src/data-compat.c
===================================================================
--- trunk/src/data-compat.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/data-compat.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -158,7 +158,7 @@
   TRACE3 (DEBUG_DATA, "gpgme:gpgme_error_to_errno", 0,
 	  "mapping %s <%s> to: %s", gpgme_strerror (err),
 	  gpgme_strsource (err), strerror (res));
-  errno = res;
+  gpg_err_set_errno (res);
   return res ? -1 : 0;
 }
 
@@ -188,7 +188,7 @@
 
   if (whence != SEEK_SET || offset)
     {
-      errno = EINVAL;
+      gpg_err_set_errno (EINVAL);
       return TRACE_SYSRES (-1);
     }
   err = (*dh->data.old_user.cb) (dh->data.old_user.handle, NULL, 0, NULL);

Modified: trunk/src/data-mem.c
===================================================================
--- trunk/src/data-mem.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/data-mem.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -115,7 +115,7 @@
     case SEEK_SET:
       if (offset < 0 || offset > dh->data.mem.length)
 	{
-	  errno = EINVAL;
+	  gpg_err_set_errno (EINVAL);
 	  return -1;
 	}
       dh->data.mem.offset = offset;
@@ -124,7 +124,7 @@
       if ((offset > 0 && dh->data.mem.length - dh->data.mem.offset < offset)
 	  || (offset < 0 && dh->data.mem.offset < -offset)) 
 	{
-	  errno = EINVAL;
+	  gpg_err_set_errno (EINVAL);
 	  return -1;
 	}
       dh->data.mem.offset += offset;
@@ -132,13 +132,13 @@
     case SEEK_END:
       if (offset > 0 || -offset > dh->data.mem.length)
 	{
-	  errno = EINVAL;
+	  gpg_err_set_errno (EINVAL);
 	  return -1;
 	}
       dh->data.mem.offset = dh->data.mem.length - offset;
       break;
     default:
-      errno = EINVAL;
+      gpg_err_set_errno (EINVAL);
       return -1;
     }
   return dh->data.mem.offset;

Modified: trunk/src/data-user.c
===================================================================
--- trunk/src/data-user.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/data-user.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -34,7 +34,7 @@
 {
   if (!dh->data.user.cbs->read)
     {
-      errno = EBADF;
+      gpg_err_set_errno (EBADF);
       return -1;
     }
 
@@ -47,7 +47,7 @@
 {
   if (!dh->data.user.cbs->write)
     {
-      errno = EBADF;
+      gpg_err_set_errno (EBADF);
       return -1;
     }
 
@@ -60,7 +60,7 @@
 {
   if (!dh->data.user.cbs->seek)
     {
-      errno = EBADF;
+      gpg_err_set_errno (EBADF);
       return -1;
     }
 

Modified: trunk/src/data.c
===================================================================
--- trunk/src/data.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/data.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -46,7 +46,7 @@
   *r_dh = NULL;
   dh = calloc (1, sizeof (*dh));
   if (!dh)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   dh->cbs = cbs;
 
@@ -79,12 +79,12 @@
 
   if (!dh)
     {
-      errno = EINVAL;
+      gpg_err_set_errno (EINVAL);
       return TRACE_SYSRES (-1);
     }
   if (!dh->cbs->read)
     {
-      errno = ENOSYS;
+      gpg_err_set_errno (ENOSYS);
       return TRACE_SYSRES (-1);
     }
   do
@@ -107,12 +107,12 @@
 
   if (!dh)
     {
-      errno = EINVAL;
+      gpg_err_set_errno (EINVAL);
       return TRACE_SYSRES (-1);
     }
   if (!dh->cbs->write)
     {
-      errno = ENOSYS;
+      gpg_err_set_errno (ENOSYS);
       return TRACE_SYSRES (-1);
     }
   do
@@ -134,12 +134,12 @@
 
   if (!dh)
     {
-      errno = EINVAL;
+      gpg_err_set_errno (EINVAL);
       return TRACE_SYSRES (-1);
     }
   if (!dh->cbs->seek)
     {
-      errno = ENOSYS;
+      gpg_err_set_errno (ENOSYS);
       return TRACE_SYSRES (-1);
     }
 
@@ -216,7 +216,7 @@
     {
       dh->file_name = strdup (file_name);
       if (!dh->file_name)
-	return TRACE_ERR (gpg_error_from_errno (errno));
+	return TRACE_ERR (gpg_error_from_syserror ());
     }
   else
     dh->file_name = 0;
@@ -257,7 +257,7 @@
 
   buflen = _gpgme_io_read (fd, buffer, BUFFER_SIZE);
   if (buflen < 0)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   if (buflen == 0)
     {
       _gpgme_io_close (fd);
@@ -268,7 +268,7 @@
     {
       ssize_t amt = gpgme_data_write (dh, bufp, buflen);
       if (amt == 0 || (amt < 0 && errno != EINTR))
-	return TRACE_ERR (gpg_error_from_errno (errno));
+	return TRACE_ERR (gpg_error_from_syserror ());
       bufp += amt;
       buflen -= amt;
     }
@@ -290,7 +290,7 @@
     {
       ssize_t amt = gpgme_data_read (dh, dh->pending, BUFFER_SIZE);
       if (amt < 0)
-	return TRACE_ERR (gpg_error_from_errno (errno));
+	return TRACE_ERR (gpg_error_from_syserror ());
       if (amt == 0)
 	{
 	  _gpgme_io_close (fd);
@@ -314,7 +314,7 @@
     }
 
   if (nwritten <= 0)
-    return TRACE_ERR (gpg_error_from_errno (errno));
+    return TRACE_ERR (gpg_error_from_syserror ());
 
   if (nwritten < dh->pending_len)
     memmove (dh->pending, dh->pending + nwritten, dh->pending_len - nwritten);

Modified: trunk/src/debug.c
===================================================================
--- trunk/src/debug.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/debug.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -231,7 +231,7 @@
   UNLOCK (debug_lock);
   fflush (errfp);
 
-  errno = saved_errno;
+  gpg_err_set_errno (saved_errno);
 }
 
 

Modified: trunk/src/decrypt.c
===================================================================
--- trunk/src/decrypt.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/decrypt.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -126,7 +126,7 @@
 
   rec = malloc (sizeof (*rec));
   if (!rec)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   rec->next = NULL;
   rec->keyid = rec->_keyid;
@@ -153,7 +153,7 @@
 
   if (*args)
     {
-      errno = 0;
+      gpg_err_set_errno (0);
       rec->pubkey_algo = strtol (args, &tail, 0);
       if (errno || args == tail || *tail != ' ')
 	{
@@ -239,7 +239,7 @@
 		  {
 		    opd->result.unsupported_algorithm = strdup (args);
 		    if (!opd->result.unsupported_algorithm)
-		      return gpg_error_from_errno (errno);
+		      return gpg_error_from_syserror ();
 		  }
 	      }
 	  }

Modified: trunk/src/delete.c
===================================================================
--- trunk/src/delete.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/delete.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -45,7 +45,7 @@
       long problem;
       char *tail;
 
-      errno = 0;
+      gpg_err_set_errno (0);
       problem = strtol (args, &tail, 0);
       if (errno || (*tail && *tail != ' '))
 	return gpg_error (GPG_ERR_INV_ENGINE);

Modified: trunk/src/engine-gpgsm.c
===================================================================
--- trunk/src/engine-gpgsm.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/engine-gpgsm.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -247,7 +247,7 @@
 
   gpgsm = calloc (1, sizeof *gpgsm);
   if (!gpgsm)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   gpgsm->status_cb.fd = -1;
   gpgsm->status_cb.dir = 1;
@@ -288,7 +288,7 @@
 #if !USE_DESCRIPTOR_PASSING
   if (_gpgme_io_pipe (fds, 0) < 0)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto leave;
     }
   gpgsm->input_cb.fd = fds[1];
@@ -296,7 +296,7 @@
 
   if (_gpgme_io_pipe (fds, 1) < 0)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto leave;
     }
   gpgsm->output_cb.fd = fds[0];
@@ -304,7 +304,7 @@
 
   if (_gpgme_io_pipe (fds, 0) < 0)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto leave;
     }
   gpgsm->message_cb.fd = fds[1];
@@ -372,7 +372,7 @@
       if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
         {
 	  free (dft_display);
-	  err = gpg_error_from_errno (errno);
+	  err = gpg_error_from_syserror ();
 	  goto leave;
 	}
       free (dft_display);
@@ -398,7 +398,7 @@
 	{
 	  if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
 	    {
-	      err = gpg_error_from_errno (errno);
+	      err = gpg_error_from_syserror ();
 	      goto leave;
 	    }
 	  err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL,
@@ -415,7 +415,7 @@
 	      if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
 		{
 		  free (dft_ttytype);
-		  err = gpg_error_from_errno (errno);
+		  err = gpg_error_from_syserror ();
 		  goto leave;
 		}
 	      free (dft_ttytype);
@@ -524,7 +524,7 @@
     return 0;
 
   if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
-    err = gpg_error_from_errno (errno);
+    err = gpg_error_from_syserror ();
   else
     {
       err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL,
@@ -660,7 +660,7 @@
       int fds[2];
 
       if (_gpgme_io_pipe (fds, dir) < 0)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
 
       iocb_data->fd = dir ? fds[0] : fds[1];
       iocb_data->server_fd = dir ? fds[1] : fds[0];
@@ -832,7 +832,7 @@
 	    {
 	      char *newline = realloc (*aline, *alinelen + linelen + 1);
 	      if (!newline)
-		err = gpg_error_from_errno (errno);
+		err = gpg_error_from_syserror ();
 	      else
 		{
 		  *aline = newline;
@@ -917,7 +917,7 @@
               if (!nwritten || (nwritten < 0 && errno != EINTR)
                   || nwritten > linelen)
                 {
-                  err = gpg_error_from_errno (errno);
+                  err = gpg_error_from_syserror ();
                   break;
                 }
               src += nwritten;
@@ -1115,7 +1115,7 @@
 
   line = malloc (length);
   if (!line)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   strcpy (line, "DELKEYS ");
   linep = &line[8];
@@ -1172,7 +1172,7 @@
   linelen = 10 + 40 + 1;	/* "RECIPIENT " + guess + '\0'.  */
   line = malloc (10 + 40 + 1);
   if (!line)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   strcpy (line, "RECIPIENT ");
   for (i =0; !err && recp[i]; i++)
     {
@@ -1278,7 +1278,7 @@
 
   cmd = malloc (7 + strlen (pattern) + 1);
   if (!cmd)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   strcpy (cmd, "EXPORT ");
   strcpy (&cmd[7], pattern);
 
@@ -1335,7 +1335,7 @@
     }
   line = malloc (length);
   if (!line)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   strcpy (line, "EXPORT ");
   linep = &line[7];
@@ -1552,7 +1552,7 @@
 
   /* Always send list-mode option because RESET does not reset it.  */
   if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL);
   free (line);
   if (err)
@@ -1580,7 +1580,7 @@
   /* Length is "LISTSECRETKEYS " + p + '\0'.  */
   line = malloc (15 + strlen (pattern) + 1);
   if (!line)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   if (secret_only)
     {
       strcpy (line, "LISTSECRETKEYS ");
@@ -1626,7 +1626,7 @@
 
   /* Always send list-mode option because RESET does not reset it.  */
   if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL);
   free (line);
   if (err)
@@ -1663,7 +1663,7 @@
     }
   line = malloc (length);
   if (!line)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   if (secret_only)
     {
       strcpy (line, "LISTSECRETKEYS ");
@@ -1749,7 +1749,7 @@
 	 requested.  */
 
       if (asprintf (&assuan_cmd, "OPTION include-certs %i", include_certs) < 0)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
       err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, assuan_cmd,
                                          NULL, NULL);
       free (assuan_cmd);

Modified: trunk/src/gpgme-tool.c
===================================================================
--- trunk/src/gpgme-tool.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/gpgme-tool.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -107,7 +107,7 @@
   void *pstate;
 };
 
-#define ARGP_ERR_UNKNOWN E2BIG
+#define ARGP_ERR_UNKNOWN EDEADLOCK
 #define ARGP_KEY_ARG 0
 #define ARGP_KEY_ARGS 0x1000006
 #define ARGP_KEY_END 0x1000001
@@ -1651,7 +1651,7 @@
 gpg_error_t
 gt_import_keys (gpgme_tool_t gt, char *fpr[])
 {
-  gpg_error_t err;
+  gpg_error_t err = 0;
   int cnt;
   int idx;
   gpgme_key_t *keys;

Modified: trunk/src/import.c
===================================================================
--- trunk/src/import.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/import.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -121,10 +121,10 @@
 
   import = malloc (sizeof (*import));
   if (!import)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   import->next = NULL;
 
-  errno = 0;
+  gpg_err_set_errno (0);
   nr = strtol (args, &tail, 0);
   if (errno || args == tail || *tail != ' ')
     {
@@ -189,7 +189,7 @@
 {
   char *tail;
 
-  errno = 0;
+  gpg_err_set_errno (0);
 
 #define PARSE_NEXT(x)					\
   (x) = strtol (args, &tail, 0);			\

Modified: trunk/src/op-support.c
===================================================================
--- trunk/src/op-support.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/op-support.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -182,7 +182,7 @@
   if (!inv_key)
     return gpg_error_from_errno (errno);
   inv_key->next = NULL;
-  errno = 0;
+  gpg_err_set_errno (0);
   reason = strtol (args, &tail, 0);
   if (errno || args == tail || (*tail && *tail != ' '))
     {
@@ -299,7 +299,7 @@
     {
       char *filename = strdup (args);
       if (!filename)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
 
       *filenamep = filename;
     }

Modified: trunk/src/setenv.c
===================================================================
--- trunk/src/setenv.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/setenv.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -20,6 +20,9 @@
 # include <config.h>
 #endif
 
+#include <gpg-error.h>
+#define __set_errno(ev) (gpg_err_set_errno (ev))
+
 #if HAVE_ASSUAN_H
 /* Fixme: Why do we need to include the assuan header and why the
    internal ones? */
@@ -29,12 +32,6 @@
 #define __builtin_expect(cond,val) (cond)
 
 #include <errno.h>
-#if !_LIBC
-# if !defined errno && !defined HAVE_ERRNO_DECL
-extern int errno;
-# endif
-# define __set_errno(ev) ((errno) = (ev))
-#endif
 
 #if _LIBC || HAVE_STDLIB_H
 # include <stdlib.h>

Modified: trunk/src/sign.c
===================================================================
--- trunk/src/sign.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/sign.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -149,7 +149,7 @@
 
   sig = malloc (sizeof (*sig));
   if (!sig)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   sig->next = NULL;
   switch (*args)
@@ -179,7 +179,7 @@
       return gpg_error (GPG_ERR_INV_ENGINE);
     }
 
-  errno = 0;
+  gpg_err_set_errno (0);
   sig->pubkey_algo = strtol (args, &tail, 0);
   if (errno || args == tail || *tail != ' ')
     {

Modified: trunk/src/verify.c
===================================================================
--- trunk/src/verify.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/verify.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -227,7 +227,7 @@
     {
       sig = calloc (1, sizeof (*sig));
       if (!sig)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
       if (!opd->result.signatures)
         opd->result.signatures = sig;
       if (opd->current_sig)
@@ -293,7 +293,7 @@
       /* Parse the pubkey algo.  */
       if (!end)
 	goto parse_err_sig_fail;
-      errno = 0;
+      gpg_err_set_errno (0);
       sig->pubkey_algo = strtol (end, &tail, 0);
       if (errno || end == tail || *tail != ' ')
 	goto parse_err_sig_fail;
@@ -304,7 +304,7 @@
       /* Parse the hash algo.  */
       if (!*end)
 	goto parse_err_sig_fail;
-      errno = 0;
+      gpg_err_set_errno (0);
       sig->hash_algo = strtol (end, &tail, 0);
       if (errno || end == tail || *tail != ' ')
 	goto parse_err_sig_fail;
@@ -362,7 +362,7 @@
     {
       sig->fpr = strdup (args);
       if (!sig->fpr)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
     }
   return 0;
 }
@@ -386,7 +386,7 @@
     free (sig->fpr);
   sig->fpr = strdup (args);
   if (!sig->fpr)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   /* Skip the creation date.  */
   end = strchr (end, ' ');
@@ -418,7 +418,7 @@
 	  if (end)
 	    {
 	      /* Parse the pubkey algo.  */
-	      errno = 0;
+	      gpg_err_set_errno (0);
 	      sig->pubkey_algo = strtol (end, &tail, 0);
 	      if (errno || end == tail || *tail != ' ')
 		return gpg_error (GPG_ERR_INV_ENGINE);
@@ -431,7 +431,7 @@
 		{
 		  /* Parse the hash algo.  */
 
-		  errno = 0;
+		  gpg_err_set_errno (0);
 		  sig->hash_algo = strtol (end, &tail, 0);
 		  if (errno || end == tail || *tail != ' ')
 		    return gpg_error (GPG_ERR_INV_ENGINE);
@@ -526,14 +526,14 @@
 	{
 	  dest = notation->value = malloc (len);
 	  if (!dest)
-	    return gpg_error_from_errno (errno);
+	    return gpg_error_from_syserror ();
 	}
       else
 	{
 	  int cur_len = strlen (notation->value);
 	  dest = realloc (notation->value, len + strlen (notation->value));
 	  if (!dest)
-	    return gpg_error_from_errno (errno);
+	    return gpg_error_from_syserror ();
 	  notation->value = dest;
 	  dest += cur_len;
 	}

Modified: trunk/src/w32-io.c
===================================================================
--- trunk/src/w32-io.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/w32-io.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -166,7 +166,7 @@
       TRACE1 (DEBUG_SYSIO, "gpgme:set_synchronize", hd,
 	      "DuplicateHandle failed: ec=%d", (int) GetLastError ());
       /* FIXME: Should translate the error code.  */
-      errno = EIO;
+      gpg_err_set_errno (EIO);
       return INVALID_HANDLE_VALUE;
     }
 
@@ -492,7 +492,7 @@
   ctx = find_reader (fd, 1);
   if (!ctx)
     {
-      errno = EBADF;
+      gpg_err_set_errno (EBADF);
       return TRACE_SYSRES (-1);
     }
   if (ctx->eof_shortcut)
@@ -520,7 +520,7 @@
 	  TRACE_LOG ("EOF but ctx->eof flag not set");
 	  return 0;
 	}
-      errno = ctx->error_code;
+      gpg_err_set_errno (ctx->error_code);
       return TRACE_SYSRES (-1);
     }
   
@@ -538,7 +538,7 @@
 	  TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ());
 	  UNLOCK (ctx->mutex);
 	  /* FIXME: Should translate the error code.  */
-	  errno = EIO;
+	  gpg_err_set_errno (EIO);
 	  return TRACE_SYSRES (-1);
 	}
     }
@@ -548,7 +548,7 @@
 		  ctx->have_space_ev, (int) GetLastError ());
       UNLOCK (ctx->mutex);
       /* FIXME: Should translate the error code.  */
-      errno = EIO;
+      gpg_err_set_errno (EIO);
       return TRACE_SYSRES (-1);
     }
   UNLOCK (ctx->mutex);
@@ -837,7 +837,7 @@
 	  TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ());
 	  UNLOCK (ctx->mutex);
 	  /* FIXME: Should translate the error code.  */
-	  errno = EIO;
+	  gpg_err_set_errno (EIO);
 	  return TRACE_SYSRES (-1);
 	}
       UNLOCK (ctx->mutex);
@@ -851,9 +851,9 @@
     {
       UNLOCK (ctx->mutex);
       if (ctx->error_code == ERROR_NO_DATA)
-        errno = EPIPE;
+        gpg_err_set_errno (EPIPE);
       else
-        errno = EIO;
+        gpg_err_set_errno (EIO);
       return TRACE_SYSRES (-1);
     }
 
@@ -873,7 +873,7 @@
       TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ());
       UNLOCK (ctx->mutex);
       /* FIXME: Should translate the error code.  */
-      errno = EIO;
+      gpg_err_set_errno (EIO);
       return TRACE_SYSRES (-1);
     }
   if (!SetEvent (ctx->have_data))
@@ -881,7 +881,7 @@
       TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ());
       UNLOCK (ctx->mutex);
       /* FIXME: Should translate the error code.  */
-      errno = EIO;
+      gpg_err_set_errno (EIO);
       return TRACE_SYSRES (-1);
     }
   UNLOCK (ctx->mutex);
@@ -908,7 +908,7 @@
     {
       TRACE_LOG1 ("CreatePipe failed: ec=%d", (int) GetLastError ());
       /* FIXME: Should translate the error code.  */
-      errno = EIO;
+      gpg_err_set_errno (EIO);
       return TRACE_SYSRES (-1);
     }
 
@@ -926,7 +926,7 @@
 	  CloseHandle (rh);
 	  CloseHandle (wh);
 	  /* FIXME: Should translate the error code.  */
-	  errno = EIO;
+	  gpg_err_set_errno (EIO);
 	  return TRACE_SYSRES (-1);
         }
       CloseHandle (rh);
@@ -940,7 +940,7 @@
 	  CloseHandle (rh);
 	  CloseHandle (wh);
 	  /* FIXME: Should translate the error code.  */
-	  errno = EIO;
+	  gpg_err_set_errno (EIO);
 	  return TRACE_SYSRES (-1);
 	}
     }
@@ -957,7 +957,7 @@
 	  CloseHandle (rh);
 	  CloseHandle (wh);
 	  /* FIXME: Should translate the error code.  */
-	  errno = EIO;
+	  gpg_err_set_errno (EIO);
 	  return TRACE_SYSRES (-1);
         }
       CloseHandle (wh);
@@ -971,7 +971,7 @@
 	  CloseHandle (rh);
 	  CloseHandle (wh);
 	  /* FIXME: Should translate the error code.  */
-	  errno = EIO;
+	  gpg_err_set_errno (EIO);
 	  return TRACE_SYSRES (-1);
 	}
     }
@@ -992,7 +992,7 @@
 
   if (fd == -1)
     {
-      errno = EBADF;
+      gpg_err_set_errno (EBADF);
       return TRACE_SYSRES (-1);
     }
 
@@ -1019,7 +1019,7 @@
     { 
       TRACE_LOG1 ("CloseHandle failed: ec=%d", (int) GetLastError ());
       /* FIXME: Should translate the error code.  */
-      errno = EIO;
+      gpg_err_set_errno (EIO);
       return TRACE_SYSRES (-1);
     }
 
@@ -1048,7 +1048,7 @@
   if (i == DIM (notify_table))
     {
       UNLOCK (notify_table_lock);
-      errno = EINVAL;
+      gpg_err_set_errno (EINVAL);
       return TRACE_SYSRES (-1);
     }
   notify_table[i].fd = fd;
@@ -1215,7 +1215,7 @@
       DeleteFile (tmp_name);
 
       /* FIXME: Should translate the error code.  */
-      errno = EIO;
+      gpg_err_set_errno (EIO);
       return TRACE_SYSRES (-1);
     }
 
@@ -1245,7 +1245,7 @@
 	  DeleteFile (tmp_name);
 
 	  /* FIXME: Should translate the error code.  */
-	  errno = EIO;
+	  gpg_err_set_errno (EIO);
 	  return TRACE_SYSRES (-1);
         }
       /* Return the child name of this handle.  */
@@ -1380,7 +1380,7 @@
 		      TRACE_END (dbg_help, "oops ]");
 		      TRACE_LOG ("Too many objects for WFMO!");
 		      /* FIXME: Should translate the error code.  */
-		      errno = EIO;
+		      gpg_err_set_errno (EIO);
 		      return TRACE_SYSRES (-1);
                     }
 		  waitidx[nwait] = i;
@@ -1403,7 +1403,7 @@
 		      TRACE_END (dbg_help, "oops ]");
 		      TRACE_LOG ("Too many objects for WFMO!");
 		      /* FIXME: Should translate the error code.  */
-		      errno = EIO;
+		      gpg_err_set_errno (EIO);
 		      return TRACE_SYSRES (-1);
                     }
 		  waitidx[nwait] = i;
@@ -1492,7 +1492,7 @@
   if (count < 0)
     {
       /* FIXME: Should determine a proper error code.  */
-      errno = EIO;
+      gpg_err_set_errno (EIO);
     }
   
   return TRACE_SYSRES (count);
@@ -1533,7 +1533,7 @@
     {
       TRACE_LOG1 ("DuplicateHandle failed: ec=%d\n", (int) GetLastError ());
       /* FIXME: Translate error code.  */
-      errno = EIO;
+      gpg_err_set_errno (EIO);
       return TRACE_SYSRES (-1);
     }
 
@@ -1627,7 +1627,7 @@
   res = socket (domain, type, proto);
   if (res == INVALID_SOCKET)
     {
-      errno = wsa2errno (WSAGetLastError ());
+      gpg_err_set_errno (wsa2errno (WSAGetLastError ()));
       return TRACE_SYSRES (-1);
     }
 
@@ -1648,7 +1648,7 @@
   res = connect (fd, addr, addrlen);
   if (res)
     {
-      errno = wsa2errno (WSAGetLastError ());
+      gpg_err_set_errno (wsa2errno (WSAGetLastError ()));
       return TRACE_SYSRES (-1);
     }
 

Modified: trunk/src/w32-util.c
===================================================================
--- trunk/src/w32-util.c	2010-04-19 16:59:23 UTC (rev 1460)
+++ trunk/src/w32-util.c	2010-05-06 13:39:55 UTC (rev 1461)
@@ -524,7 +524,7 @@
   len = strlen (tmpl);
   if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
     {
-      errno = EINVAL;
+      gpg_err_set_errno (EINVAL);
       return -1;
     }
 
@@ -561,7 +561,7 @@
       fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
       if (fd >= 0)
 	{
-	  errno = save_errno;
+	  gpg_err_set_errno (save_errno);
 	  return fd;
 	}
       else if (errno != EEXIST)
@@ -569,7 +569,7 @@
     }
 
   /* We got out of the loop because we ran out of combinations to try.  */
-  errno = EEXIST;
+  gpg_err_set_errno (EEXIST);
   return -1;
 }
 




More information about the Gnupg-commits mailing list