[Pkg-gnupg-commit] [gnupg2] 127/292: common, w32: Make use of default_errsource in exechelp.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:33 UTC 2016


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

dkg pushed a commit to branch master
in repository gnupg2.

commit 727ca74bb942464217e678012cccbfc347ae08a5
Author: Justus Winter <justus at g10code.com>
Date:   Tue Oct 18 14:01:53 2016 +0200

    common,w32: Make use of default_errsource in exechelp.
    
    * common/exechelp-posix.c (my_error_from_syserror, my_error): New.
    Use them instead of gpg_error and gpg_error_from_syserror.
    
    Fixes-commit: 96c7901ec1c79be732570811223d3ea54875abfe
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 common/exechelp-w32.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c
index b2d2457..418eb9b 100644
--- a/common/exechelp-w32.c
+++ b/common/exechelp-w32.c
@@ -84,6 +84,20 @@
 # define handle_to_pid(a) ((int)(a))
 
 
+/* Helper */
+static inline gpg_error_t
+my_error_from_syserror (void)
+{
+  return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
+}
+
+static inline gpg_error_t
+my_error (int errcode)
+{
+  return gpg_err_make (default_errsource, errcode);
+}
+
+
 /* Return the maximum number of currently allowed open file
    descriptors.  Only useful on POSIX systems but returns a value on
    other systems too.  */
@@ -219,7 +233,7 @@ build_w32_commandline (const char *pgmname, const char * const *argv,
 
   buf = p = xtrymalloc (n);
   if (!buf)
-    return gpg_error_from_syserror ();
+    return my_error_from_syserror ();
 
   p = build_w32_commandline_copy (p, pgmname);
   for (i=0; argv[i]; i++)
@@ -293,7 +307,7 @@ do_create_pipe (int filedes[2], int flags)
   HANDLE fds[2];
 
   filedes[0] = filedes[1] = -1;
-  err = gpg_error (GPG_ERR_GENERAL);
+  err = my_error (GPG_ERR_GENERAL);
   if (!create_inheritable_pipe (fds, flags))
     {
       filedes[0] = _open_osfhandle (handle_to_fd (fds[0]), O_RDONLY);
@@ -662,7 +676,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
                       ))
     {
       log_error ("CreateProcess failed: %s\n", w32_strerror (-1));
-      err = gpg_error (GPG_ERR_GENERAL);
+      err = my_error (GPG_ERR_GENERAL);
     }
   else
     err = 0;
@@ -707,7 +721,7 @@ gnupg_wait_processes (const char **pgmnames, pid_t *pids, size_t count,
 
   procs = xtrycalloc (count, sizeof *procs);
   if (procs == NULL)
-    return gpg_error_from_syserror ();
+    return my_error_from_syserror ();
 
   for (i = 0; i < count; i++)
     {
@@ -715,7 +729,7 @@ gnupg_wait_processes (const char **pgmnames, pid_t *pids, size_t count,
         r_exitcodes[i] = -1;
 
       if (pids[i] == (pid_t)(-1))
-        return gpg_error (GPG_ERR_INV_VALUE);
+        return my_error (GPG_ERR_INV_VALUE);
 
       procs[i] = fd_to_handle (pids[i]);
     }
@@ -818,7 +832,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
   (void)envp;
 
   if (access (pgmname, X_OK))
-    return gpg_error_from_syserror ();
+    return my_error_from_syserror ();
 
   /* Prepare security attributes.  */
   memset (&sec_attr, 0, sizeof sec_attr );
@@ -856,7 +870,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
     {
       log_error ("CreateProcess(detached) failed: %s\n", w32_strerror (-1));
       xfree (cmdline);
-      return gpg_error (GPG_ERR_GENERAL);
+      return my_error (GPG_ERR_GENERAL);
     }
   xfree (cmdline);
   cmdline = NULL;

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