diff options
author | Justus Winter <justus@g10code.com> | 2016-10-18 14:01:53 +0200 |
---|---|---|
committer | Justus Winter <justus@g10code.com> | 2016-10-18 18:54:49 +0200 |
commit | 727ca74bb942464217e678012cccbfc347ae08a5 (patch) | |
tree | 3a101a6eed5b6a2df2653fbd9f672c318ffffb0a /common/exechelp-w32.c | |
parent | scd: Support ECC key generation. (diff) | |
download | gnupg2-727ca74bb942464217e678012cccbfc347ae08a5.tar.xz gnupg2-727ca74bb942464217e678012cccbfc347ae08a5.zip |
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@g10code.com>
Diffstat (limited to 'common/exechelp-w32.c')
-rw-r--r-- | common/exechelp-w32.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c index b2d2457f6..418eb9b55 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; |