From: Marcus Brinkmann Date: Thu, 6 May 2010 13:39:55 +0000 (+0000) Subject: 2010-05-06 Marcus Brinkmann X-Git-Tag: gpgme-1.3.1~73 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=749325d6c10fd6a8d8fafa3c9c25b6822eaf0dc5;p=gpgme.git 2010-05-06 Marcus Brinkmann * configure.ac: Require libgpg-error 1.8. src/ 2010-05-06 Marcus Brinkmann * 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 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. --- diff --git a/ChangeLog b/ChangeLog index 185bb85..834abce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-05-06 Marcus Brinkmann + + * configure.ac: Require libgpg-error 1.8. + 2010-03-15 Werner Koch * configure.ac (emacs_local_vars_begin) diff --git a/README b/README index 01d7d3a..a3ce1f4 100644 --- a/README +++ b/README @@ -41,7 +41,7 @@ Check that you have unmodified sources. See below on how to do this. 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: diff --git a/configure.ac b/configure.ac index 9b3b0d4..79d0904 100644 --- a/configure.ac +++ b/configure.ac @@ -283,7 +283,7 @@ if test "$ac_cv_func_timegm" != yes; then 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.]) diff --git a/src/assuan-support.c b/src/assuan-support.c index 7b2a725..676874c 100644 --- a/src/assuan-support.c +++ b/src/assuan-support.c @@ -77,7 +77,7 @@ my_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, 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 @@ my_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg, 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 @@ my_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name, if (! name) { - errno = ENOSYS; + gpg_err_set_errno (ENOSYS); return -1; } @@ -203,7 +203,7 @@ my_socketpair (assuan_context_t ctx, int namespace, int style, 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. */ diff --git a/src/conversion.c b/src/conversion.c index 538a5f8..f70172b 100644 --- a/src/conversion.c +++ b/src/conversion.c @@ -93,7 +93,7 @@ _gpgme_decode_c_string (const char *src, char **destp, size_t len) 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 @@ _gpgme_decode_percent_string (const char *src, char **destp, size_t len, 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 @@ _gpgme_encode_percent_string (const char *src, char **destp, size_t len) string. */ dest = malloc (destlen); if (!dest) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); *destp = dest; } diff --git a/src/data-compat.c b/src/data-compat.c index cabe24e..76d6cd0 100644 --- a/src/data-compat.c +++ b/src/data-compat.c @@ -158,7 +158,7 @@ gpgme_error_to_errno (gpgme_error_t err) 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 @@ old_user_seek (gpgme_data_t dh, off_t offset, int whence) 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); diff --git a/src/data-mem.c b/src/data-mem.c index 5dca89a..7be72bf 100644 --- a/src/data-mem.c +++ b/src/data-mem.c @@ -115,7 +115,7 @@ mem_seek (gpgme_data_t dh, off_t offset, int whence) 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 @@ mem_seek (gpgme_data_t dh, off_t offset, int whence) 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 @@ mem_seek (gpgme_data_t dh, off_t offset, int whence) 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; diff --git a/src/data-user.c b/src/data-user.c index de81c7b..79e62ba 100644 --- a/src/data-user.c +++ b/src/data-user.c @@ -34,7 +34,7 @@ user_read (gpgme_data_t dh, void *buffer, size_t size) { if (!dh->data.user.cbs->read) { - errno = EBADF; + gpg_err_set_errno (EBADF); return -1; } @@ -47,7 +47,7 @@ user_write (gpgme_data_t dh, const void *buffer, size_t size) { if (!dh->data.user.cbs->write) { - errno = EBADF; + gpg_err_set_errno (EBADF); return -1; } @@ -60,7 +60,7 @@ user_seek (gpgme_data_t dh, off_t offset, int whence) { if (!dh->data.user.cbs->seek) { - errno = EBADF; + gpg_err_set_errno (EBADF); return -1; } diff --git a/src/data.c b/src/data.c index 408aeab..be64ef0 100644 --- a/src/data.c +++ b/src/data.c @@ -46,7 +46,7 @@ _gpgme_data_new (gpgme_data_t *r_dh, struct _gpgme_data_cbs *cbs) *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 @@ gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size) 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 @@ gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size) 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 @@ gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence) 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 @@ gpgme_data_set_file_name (gpgme_data_t dh, const char *file_name) { 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 @@ _gpgme_data_inbound_handler (void *opaque, int fd) 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 @@ _gpgme_data_inbound_handler (void *opaque, int fd) { 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 @@ _gpgme_data_outbound_handler (void *opaque, int fd) { 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 @@ _gpgme_data_outbound_handler (void *opaque, int fd) } 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); diff --git a/src/debug.c b/src/debug.c index 38e0cca..e51ece6 100644 --- a/src/debug.c +++ b/src/debug.c @@ -231,7 +231,7 @@ _gpgme_debug (int level, const char *format, ...) UNLOCK (debug_lock); fflush (errfp); - errno = saved_errno; + gpg_err_set_errno (saved_errno); } diff --git a/src/decrypt.c b/src/decrypt.c index 132a04b..87ae460 100644 --- a/src/decrypt.c +++ b/src/decrypt.c @@ -126,7 +126,7 @@ parse_enc_to (char *args, gpgme_recipient_t *recp) 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 @@ parse_enc_to (char *args, gpgme_recipient_t *recp) 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 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code, { opd->result.unsupported_algorithm = strdup (args); if (!opd->result.unsupported_algorithm) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } } } diff --git a/src/delete.c b/src/delete.c index 0cd3e94..c5a92f1 100644 --- a/src/delete.c +++ b/src/delete.c @@ -45,7 +45,7 @@ delete_status_handler (void *priv, gpgme_status_code_t code, char *args) 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); diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 76760d5..dd1ea3e 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -247,7 +247,7 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) 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 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) #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 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) 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 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) 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 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) 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 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) { 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 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) 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 @@ gpgsm_set_locale (void *engine, int category, const char *value) 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 @@ gpgsm_set_fd (engine_gpgsm_t gpgsm, fd_type_t fd_type, const char *opt) 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 @@ status_handler (void *opaque, int fd) { 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 @@ status_handler (void *opaque, int fd) 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 @@ gpgsm_delete (void *engine, gpgme_key_t key, int allow_secret) 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 @@ set_recipients (engine_gpgsm_t gpgsm, gpgme_key_t recp[]) 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 @@ gpgsm_export (void *engine, const char *pattern, gpgme_export_mode_t mode, 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 @@ gpgsm_export_ext (void *engine, const char *pattern[], gpgme_export_mode_t mode, } 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 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only, /* 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 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only, /* 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 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only, /* 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 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only, } 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 @@ gpgsm_sign (void *engine, gpgme_data_t in, gpgme_data_t out, 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); diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c index 57dcba3..2624759 100644 --- a/src/gpgme-tool.c +++ b/src/gpgme-tool.c @@ -107,7 +107,7 @@ struct argp_state 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 @@ gt_genkey (gpgme_tool_t gt, const char *parms, gpgme_data_t public, 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; diff --git a/src/import.c b/src/import.c index ffab955..ff5f9b3 100644 --- a/src/import.c +++ b/src/import.c @@ -121,10 +121,10 @@ parse_import (char *args, gpgme_import_status_t *import_status, int problem) 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 @@ parse_import_res (char *args, gpgme_import_result_t result) { char *tail; - errno = 0; + gpg_err_set_errno (0); #define PARSE_NEXT(x) \ (x) = strtol (args, &tail, 0); \ diff --git a/src/op-support.c b/src/op-support.c index b3cf55e..6738536 100644 --- a/src/op-support.c +++ b/src/op-support.c @@ -182,7 +182,7 @@ _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key) 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 @@ _gpgme_parse_plaintext (char *args, char **filenamep) { char *filename = strdup (args); if (!filename) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); *filenamep = filename; } diff --git a/src/setenv.c b/src/setenv.c index d3a54c1..5a7e638 100644 --- a/src/setenv.c +++ b/src/setenv.c @@ -20,6 +20,9 @@ # include #endif +#include +#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 -#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 diff --git a/src/sign.c b/src/sign.c index 3d860da..8aff542 100644 --- a/src/sign.c +++ b/src/sign.c @@ -149,7 +149,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp) 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 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp) 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 != ' ') { diff --git a/src/verify.c b/src/verify.c index ab74ec2..ed81b8a 100644 --- a/src/verify.c +++ b/src/verify.c @@ -227,7 +227,7 @@ prepare_new_sig (op_data_t opd) { 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_new_sig (op_data_t opd, gpgme_status_code_t code, char *args) /* 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_new_sig (op_data_t opd, gpgme_status_code_t code, char *args) /* 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 @@ parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args) { sig->fpr = strdup (args); if (!sig->fpr) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } return 0; } @@ -386,7 +386,7 @@ parse_valid_sig (gpgme_signature_t sig, char *args) 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 @@ parse_valid_sig (gpgme_signature_t sig, char *args) 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_valid_sig (gpgme_signature_t sig, char *args) { /* 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 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args) { 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; } diff --git a/src/w32-io.c b/src/w32-io.c index d05db70..d11a3e6 100644 --- a/src/w32-io.c +++ b/src/w32-io.c @@ -166,7 +166,7 @@ set_synchronize (HANDLE hd) 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 @@ _gpgme_io_read (int fd, void *buffer, size_t count) 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 @@ _gpgme_io_read (int fd, void *buffer, size_t count) 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 @@ _gpgme_io_read (int fd, void *buffer, size_t count) 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 @@ _gpgme_io_read (int fd, void *buffer, size_t count) 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 @@ _gpgme_io_write (int fd, const void *buffer, size_t count) 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 @@ _gpgme_io_write (int fd, const void *buffer, size_t count) { 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 @@ _gpgme_io_write (int fd, const void *buffer, size_t count) 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 @@ _gpgme_io_write (int fd, const void *buffer, size_t count) 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 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx) { 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 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx) 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 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx) 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 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx) 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 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx) 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 @@ _gpgme_io_close (int fd) if (fd == -1) { - errno = EBADF; + gpg_err_set_errno (EBADF); return TRACE_SYSRES (-1); } @@ -1019,7 +1019,7 @@ _gpgme_io_close (int fd) { 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 @@ _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, 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 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags, DeleteFile (tmp_name); /* FIXME: Should translate the error code. */ - errno = EIO; + gpg_err_set_errno (EIO); return TRACE_SYSRES (-1); } @@ -1245,7 +1245,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags, 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 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) 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 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) 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 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) 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 @@ _gpgme_io_dup (int fd) { 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 @@ _gpgme_io_socket (int domain, int type, int proto) 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 @@ _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen) res = connect (fd, addr, addrlen); if (res) { - errno = wsa2errno (WSAGetLastError ()); + gpg_err_set_errno (wsa2errno (WSAGetLastError ())); return TRACE_SYSRES (-1); } diff --git a/src/w32-util.c b/src/w32-util.c index bc18602..ef524f7 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -524,7 +524,7 @@ mkstemp (char *tmpl) len = strlen (tmpl); if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX")) { - errno = EINVAL; + gpg_err_set_errno (EINVAL); return -1; } @@ -561,7 +561,7 @@ mkstemp (char *tmpl) 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 @@ mkstemp (char *tmpl) } /* We got out of the loop because we ran out of combinations to try. */ - errno = EEXIST; + gpg_err_set_errno (EEXIST); return -1; }