Use gpg_error_from_syserror instead of directly accessing errno.

--

Also fixed a couple of minor thing; e.g. save the error before calling
cleanup functions.  Do not save the errno if only free is called
in between.
This commit is contained in:
Werner Koch 2013-02-06 17:35:40 +01:00
parent 322552a88d
commit 51fd6d8292
27 changed files with 133 additions and 135 deletions

View File

@ -60,7 +60,7 @@ gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname,
if (fname) if (fname)
stream = fopen (fname, "rb"); stream = fopen (fname, "rb");
if (!stream) if (!stream)
return TRACE_ERR (gpg_error_from_errno (errno)); return TRACE_ERR (gpg_error_from_syserror ());
#ifdef HAVE_FSEEKO #ifdef HAVE_FSEEKO
res = fseeko (stream, offset, SEEK_SET); res = fseeko (stream, offset, SEEK_SET);
@ -71,31 +71,31 @@ gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname,
if (res) if (res)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
if (fname) if (fname)
fclose (stream); fclose (stream);
return TRACE_ERR (gpg_error_from_errno (saved_errno)); return TRACE_ERR (saved_err);
} }
buf = malloc (length); buf = malloc (length);
if (!buf) if (!buf)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
if (fname) if (fname)
fclose (stream); fclose (stream);
return TRACE_ERR (gpg_error_from_errno (saved_errno)); return TRACE_ERR (saved_err);
} }
while (fread (buf, length, 1, stream) < 1 while (fread (buf, length, 1, stream) < 1
&& ferror (stream) && errno == EINTR); && ferror (stream) && errno == EINTR);
if (ferror (stream)) if (ferror (stream))
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
if (buf) if (buf)
free (buf); free (buf);
if (fname) if (fname)
fclose (stream); fclose (stream);
return TRACE_ERR (gpg_error_from_errno (saved_errno)); return TRACE_ERR (saved_err);
} }
if (fname) if (fname)
@ -135,7 +135,7 @@ gpgme_data_new_from_file (gpgme_data_t *r_dh, const char *fname, int copy)
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (stat (fname, &statbuf) < 0) if (stat (fname, &statbuf) < 0)
return TRACE_ERR (gpg_error_from_errno (errno)); return TRACE_ERR (gpg_error_from_syserror ());
err = gpgme_data_new_from_filepart (r_dh, fname, NULL, 0, statbuf.st_size); err = gpgme_data_new_from_filepart (r_dh, fname, NULL, 0, statbuf.st_size);
return TRACE_ERR (err); return TRACE_ERR (err);
@ -247,8 +247,8 @@ gpgme_data_rewind (gpgme_data_t dh)
gpgme_error_t err; gpgme_error_t err;
TRACE_BEG (DEBUG_DATA, "gpgme_data_rewind", dh); TRACE_BEG (DEBUG_DATA, "gpgme_data_rewind", dh);
err = (gpgme_data_seek (dh, 0, SEEK_SET) == -1) err = ((gpgme_data_seek (dh, 0, SEEK_SET) == -1)
? gpg_error_from_errno (errno) : 0; ? gpg_error_from_syserror () : 0);
return TRACE_ERR (err); return TRACE_ERR (err);
} }

View File

@ -202,9 +202,9 @@ gpgme_data_new_from_mem (gpgme_data_t *r_dh, const char *buffer,
char *bufcpy = malloc (size); char *bufcpy = malloc (size);
if (!bufcpy) if (!bufcpy)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
_gpgme_data_release (*r_dh); _gpgme_data_release (*r_dh);
return TRACE_ERR (gpg_error_from_errno (saved_errno)); return TRACE_ERR (saved_err);
} }
memcpy (bufcpy, buffer, size); memcpy (bufcpy, buffer, size);
(*r_dh)->data.mem.buffer = bufcpy; (*r_dh)->data.mem.buffer = bufcpy;
@ -242,9 +242,9 @@ gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len)
str = malloc (dh->data.mem.length); str = malloc (dh->data.mem.length);
if (!str) if (!str)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
gpgme_data_release (dh); gpgme_data_release (dh);
TRACE_ERR (gpg_error_from_errno (saved_errno)); TRACE_ERR (saved_err);
return NULL; return NULL;
} }
memcpy (str, dh->data.mem.orig_buffer, dh->data.mem.length); memcpy (str, dh->data.mem.orig_buffer, dh->data.mem.length);

View File

@ -394,7 +394,7 @@ llass_set_locale (void *engine, int category, const char *value)
return 0; return 0;
if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0) if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
{ {
err = assuan_transact (llass->assuan_ctx, optstr, NULL, NULL, err = assuan_transact (llass->assuan_ctx, optstr, NULL, NULL,

View File

@ -225,7 +225,7 @@ g13_new (void **engine, const char *file_name, const char *home_dir)
g13 = calloc (1, sizeof *g13); g13 = calloc (1, sizeof *g13);
if (!g13) if (!g13)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
g13->status_cb.fd = -1; g13->status_cb.fd = -1;
g13->status_cb.dir = 1; g13->status_cb.dir = 1;
@ -269,7 +269,7 @@ g13_new (void **engine, const char *file_name, const char *home_dir)
if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0) if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
{ {
free (dft_display); free (dft_display);
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
free (dft_display); free (dft_display);
@ -295,7 +295,7 @@ g13_new (void **engine, const char *file_name, const char *home_dir)
{ {
if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0) if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
err = assuan_transact (g13->assuan_ctx, optstr, NULL, NULL, NULL, err = assuan_transact (g13->assuan_ctx, optstr, NULL, NULL, NULL,
@ -312,7 +312,7 @@ g13_new (void **engine, const char *file_name, const char *home_dir)
if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0) if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
{ {
free (dft_ttytype); free (dft_ttytype);
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
free (dft_ttytype); free (dft_ttytype);
@ -390,7 +390,7 @@ g13_set_locale (void *engine, int category, const char *value)
return 0; return 0;
if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0) if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
{ {
err = assuan_transact (g13->assuan_ctx, optstr, NULL, NULL, err = assuan_transact (g13->assuan_ctx, optstr, NULL, NULL,

View File

@ -210,7 +210,7 @@ _add_arg (engine_gpg_t gpg, const char *arg, int front, int *arg_locp)
a = malloc (sizeof *a + strlen (arg)); a = malloc (sizeof *a + strlen (arg));
if (!a) if (!a)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
a->data = NULL; a->data = NULL;
a->dup_to = -1; a->dup_to = -1;
@ -269,7 +269,7 @@ add_data (engine_gpg_t gpg, gpgme_data_t data, int dup_to, int inbound)
a = malloc (sizeof *a - 1); a = malloc (sizeof *a - 1);
if (!a) if (!a)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
a->next = NULL; a->next = NULL;
a->data = data; a->data = data;
a->inbound = inbound; a->inbound = inbound;
@ -424,14 +424,14 @@ gpg_new (void **engine, const char *file_name, const char *home_dir)
gpg = calloc (1, sizeof *gpg); gpg = calloc (1, sizeof *gpg);
if (!gpg) if (!gpg)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
if (file_name) if (file_name)
{ {
gpg->file_name = strdup (file_name); gpg->file_name = strdup (file_name);
if (!gpg->file_name) if (!gpg->file_name)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
goto leave; goto leave;
} }
} }
@ -452,14 +452,14 @@ gpg_new (void **engine, const char *file_name, const char *home_dir)
gpg->status.buffer = malloc (gpg->status.bufsize); gpg->status.buffer = malloc (gpg->status.bufsize);
if (!gpg->status.buffer) if (!gpg->status.buffer)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
goto leave; goto leave;
} }
/* In any case we need a status pipe - create it right here and /* In any case we need a status pipe - create it right here and
don't handle it with our generic gpgme_data_t mechanism. */ don't handle it with our generic gpgme_data_t mechanism. */
if (_gpgme_io_pipe (gpg->status.fd, 1) == -1) if (_gpgme_io_pipe (gpg->status.fd, 1) == -1)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
goto leave; goto leave;
} }
if (_gpgme_io_set_close_notify (gpg->status.fd[0], if (_gpgme_io_set_close_notify (gpg->status.fd[0],
@ -630,14 +630,14 @@ gpg_set_colon_line_handler (void *engine, engine_colon_line_handler_t fnc,
gpg->colon.readpos = 0; gpg->colon.readpos = 0;
gpg->colon.buffer = malloc (gpg->colon.bufsize); gpg->colon.buffer = malloc (gpg->colon.bufsize);
if (!gpg->colon.buffer) if (!gpg->colon.buffer)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
if (_gpgme_io_pipe (gpg->colon.fd, 1) == -1) if (_gpgme_io_pipe (gpg->colon.fd, 1) == -1)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (gpg->colon.buffer); free (gpg->colon.buffer);
gpg->colon.buffer = NULL; gpg->colon.buffer = NULL;
return gpg_error_from_errno (saved_errno); return saved_err;
} }
if (_gpgme_io_set_close_notify (gpg->colon.fd[0], close_notify_handler, gpg) if (_gpgme_io_set_close_notify (gpg->colon.fd[0], close_notify_handler, gpg)
|| _gpgme_io_set_close_notify (gpg->colon.fd[1], || _gpgme_io_set_close_notify (gpg->colon.fd[1],
@ -775,23 +775,23 @@ build_argv (engine_gpg_t gpg)
argv = calloc (argc + 1, sizeof *argv); argv = calloc (argc + 1, sizeof *argv);
if (!argv) if (!argv)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
fd_data_map = calloc (datac + 1, sizeof *fd_data_map); fd_data_map = calloc (datac + 1, sizeof *fd_data_map);
if (!fd_data_map) if (!fd_data_map)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free_argv (argv); free_argv (argv);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
argc = datac = 0; argc = datac = 0;
argv[argc] = strdup ("gpg"); /* argv[0] */ argv[argc] = strdup ("gpg"); /* argv[0] */
if (!argv[argc]) if (!argv[argc])
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
argc++; argc++;
if (need_special) if (need_special)
@ -799,10 +799,10 @@ build_argv (engine_gpg_t gpg)
argv[argc] = strdup ("--enable-special-filenames"); argv[argc] = strdup ("--enable-special-filenames");
if (!argv[argc]) if (!argv[argc])
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
argc++; argc++;
} }
@ -811,10 +811,10 @@ build_argv (engine_gpg_t gpg)
argv[argc] = strdup ("--use-agent"); argv[argc] = strdup ("--use-agent");
if (!argv[argc]) if (!argv[argc])
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
argc++; argc++;
} }
@ -823,20 +823,20 @@ build_argv (engine_gpg_t gpg)
argv[argc] = strdup ("--batch"); argv[argc] = strdup ("--batch");
if (!argv[argc]) if (!argv[argc])
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
argc++; argc++;
} }
argv[argc] = strdup ("--no-sk-comment"); argv[argc] = strdup ("--no-sk-comment");
if (!argv[argc]) if (!argv[argc])
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
argc++; argc++;
for (a = gpg->arglist; a; a = a->next) for (a = gpg->arglist; a; a = a->next)
@ -908,10 +908,10 @@ build_argv (engine_gpg_t gpg)
argv[argc] = malloc (buflen); argv[argc] = malloc (buflen);
if (!argv[argc]) if (!argv[argc])
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
ptr = argv[argc]; ptr = argv[argc];
@ -933,10 +933,10 @@ build_argv (engine_gpg_t gpg)
argv[argc] = strdup (a->arg); argv[argc] = strdup (a->arg);
if (!argv[argc]) if (!argv[argc])
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
argc++; argc++;
} }
@ -987,13 +987,13 @@ read_status (engine_gpg_t gpg)
bufsize += 1024; bufsize += 1024;
buffer = realloc (buffer, bufsize); buffer = realloc (buffer, bufsize);
if (!buffer) if (!buffer)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
nread = _gpgme_io_read (gpg->status.fd[0], nread = _gpgme_io_read (gpg->status.fd[0],
buffer + readpos, bufsize-readpos); buffer + readpos, bufsize-readpos);
if (nread == -1) if (nread == -1)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
if (!nread) if (!nread)
{ {
@ -1043,7 +1043,7 @@ read_status (engine_gpg_t gpg)
free (gpg->cmd.keyword); free (gpg->cmd.keyword);
gpg->cmd.keyword = strdup (rest); gpg->cmd.keyword = strdup (rest);
if (!gpg->cmd.keyword) if (!gpg->cmd.keyword)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
/* This should be the last thing we have /* This should be the last thing we have
received and the next thing will be that received and the next thing will be that
the command handler does its action. */ the command handler does its action. */
@ -1163,12 +1163,12 @@ read_colon_line (engine_gpg_t gpg)
bufsize += 1024; bufsize += 1024;
buffer = realloc (buffer, bufsize); buffer = realloc (buffer, bufsize);
if (!buffer) if (!buffer)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
nread = _gpgme_io_read (gpg->colon.fd[0], buffer+readpos, bufsize-readpos); nread = _gpgme_io_read (gpg->colon.fd[0], buffer+readpos, bufsize-readpos);
if (nread == -1) if (nread == -1)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
if (!nread) if (!nread)
{ {
@ -1259,7 +1259,6 @@ static gpgme_error_t
start (engine_gpg_t gpg) start (engine_gpg_t gpg)
{ {
gpgme_error_t rc; gpgme_error_t rc;
int saved_errno;
int i, n; int i, n;
int status; int status;
struct spawn_fd_item_s *fd_list; struct spawn_fd_item_s *fd_list;
@ -1299,7 +1298,7 @@ start (engine_gpg_t gpg)
n++; n++;
fd_list = calloc (n, sizeof *fd_list); fd_list = calloc (n, sizeof *fd_list);
if (! fd_list) if (! fd_list)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
/* Build the fd list for the child. */ /* Build the fd list for the child. */
n = 0; n = 0;
@ -1327,11 +1326,12 @@ start (engine_gpg_t gpg)
_gpgme_get_gpg_path (), gpg->argv, _gpgme_get_gpg_path (), gpg->argv,
IOSPAWN_FLAG_ALLOW_SET_FG, IOSPAWN_FLAG_ALLOW_SET_FG,
fd_list, NULL, NULL, &pid); fd_list, NULL, NULL, &pid);
saved_errno = errno; {
int saved_err = gpg_error_from_syserror ();
free (fd_list); free (fd_list);
if (status == -1) if (status == -1)
return gpg_error_from_errno (saved_errno); return saved_err;
}
/*_gpgme_register_term_handler ( closure, closure_value, pid );*/ /*_gpgme_register_term_handler ( closure, closure_value, pid );*/
@ -1495,7 +1495,7 @@ append_args_from_sig_notations (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */)
arg = malloc (1 + notation->name_len + 1 + notation->value_len + 1); arg = malloc (1 + notation->name_len + 1 + notation->value_len + 1);
if (!arg) if (!arg)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
if (!err) if (!err)
{ {
@ -1531,7 +1531,7 @@ append_args_from_sig_notations (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */)
{ {
value = malloc (1 + notation->value_len + 1); value = malloc (1 + notation->value_len + 1);
if (!value) if (!value)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
{ {
value[0] = '!'; value[0] = '!';
@ -2061,7 +2061,7 @@ gpg_keylist_preprocess (char *line, char **r_line)
if (asprintf (r_line, "pub:o%s:%s:%s:%s:%s:%s::::::::", if (asprintf (r_line, "pub:o%s:%s:%s:%s:%s:%s::::::::",
field[6], field[3], field[2], field[1], field[6], field[3], field[2], field[1],
field[4], field[5]) < 0) field[4], field[5]) < 0)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
return 0; return 0;
case RT_UID: case RT_UID:
@ -2086,7 +2086,7 @@ gpg_keylist_preprocess (char *line, char **r_line)
char *dst; char *dst;
if (! uid) if (! uid)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
src = field[1]; src = field[1];
dst = uid; dst = uid;
while (*src) while (*src)
@ -2114,7 +2114,7 @@ gpg_keylist_preprocess (char *line, char **r_line)
if (asprintf (r_line, "uid:o%s::::%s:%s:::%s:", if (asprintf (r_line, "uid:o%s::::%s:%s:::%s:",
field[4], field[2], field[3], uid) < 0) field[4], field[2], field[3], uid) < 0)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
return 0; return 0;

View File

@ -96,7 +96,7 @@ gpgconf_new (void **engine, const char *file_name, const char *home_dir)
gpgconf = calloc (1, sizeof *gpgconf); gpgconf = calloc (1, sizeof *gpgconf);
if (!gpgconf) if (!gpgconf)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
gpgconf->file_name = strdup (file_name ? file_name gpgconf->file_name = strdup (file_name ? file_name
: _gpgme_get_gpgconf_path ()); : _gpgme_get_gpgconf_path ());

View File

@ -1196,9 +1196,9 @@ set_recipients (engine_gpgsm_t gpgsm, gpgme_key_t recp[])
char *newline = realloc (line, newlen); char *newline = realloc (line, newlen);
if (! newline) if (! newline)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (line); free (line);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
line = newline; line = newline;
linelen = newlen; linelen = newlen;

View File

@ -308,8 +308,8 @@ uiserver_new (void **engine, const char *file_name, const char *home_dir)
{ {
if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0) if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
{ {
err = gpg_error_from_syserror ();
free (dft_display); free (dft_display);
err = gpg_error_from_errno (errno);
goto leave; goto leave;
} }
free (dft_display); free (dft_display);
@ -335,7 +335,7 @@ uiserver_new (void **engine, const char *file_name, const char *home_dir)
{ {
if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0) if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL, NULL, err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL, NULL,
@ -351,8 +351,8 @@ uiserver_new (void **engine, const char *file_name, const char *home_dir)
{ {
if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0) if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
{ {
err = gpg_error_from_syserror ();
free (dft_ttytype); free (dft_ttytype);
err = gpg_error_from_errno (errno);
goto leave; goto leave;
} }
free (dft_ttytype); free (dft_ttytype);
@ -425,7 +425,7 @@ uiserver_set_locale (void *engine, int category, const char *value)
return 0; return 0;
if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0) if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
{ {
err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL, err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL,
@ -553,7 +553,7 @@ uiserver_set_fd (engine_uiserver_t uiserver, fd_type_t fd_type, const char *opt)
int fds[2]; int fds[2];
if (_gpgme_io_pipe (fds, 0) < 0) if (_gpgme_io_pipe (fds, 0) < 0)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
iocb_data->fd = dir ? fds[0] : fds[1]; iocb_data->fd = dir ? fds[0] : fds[1];
iocb_data->server_fd = dir ? fds[1] : fds[0]; iocb_data->server_fd = dir ? fds[1] : fds[0];
@ -694,7 +694,7 @@ status_handler (void *opaque, int fd)
{ {
char *newline = realloc (*aline, *alinelen + linelen + 1); char *newline = realloc (*aline, *alinelen + linelen + 1);
if (!newline) if (!newline)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
{ {
*aline = newline; *aline = newline;
@ -779,7 +779,7 @@ status_handler (void *opaque, int fd)
if (!nwritten || (nwritten < 0 && errno != EINTR) if (!nwritten || (nwritten < 0 && errno != EINTR)
|| nwritten > linelen) || nwritten > linelen)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
break; break;
} }
src += nwritten; src += nwritten;
@ -943,7 +943,7 @@ _uiserver_decrypt (void *engine, int verify,
if (asprintf (&cmd, "DECRYPT%s%s", protocol, if (asprintf (&cmd, "DECRYPT%s%s", protocol,
verify ? "" : " --no-verify") < 0) verify ? "" : " --no-verify") < 0)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
uiserver->input_cb.data = ciph; uiserver->input_cb.data = ciph;
err = uiserver_set_fd (uiserver, INPUT_FD, err = uiserver_set_fd (uiserver, INPUT_FD,
@ -995,7 +995,7 @@ set_recipients (engine_uiserver_t uiserver, gpgme_key_t recp[])
linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */ linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */
line = malloc (10 + 40 + 1); line = malloc (10 + 40 + 1);
if (!line) if (!line)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
strcpy (line, "RECIPIENT "); strcpy (line, "RECIPIENT ");
for (i=0; !err && recp[i]; i++) for (i=0; !err && recp[i]; i++)
{ {
@ -1015,9 +1015,9 @@ set_recipients (engine_uiserver_t uiserver, gpgme_key_t recp[])
char *newline = realloc (line, newlen); char *newline = realloc (line, newlen);
if (! newline) if (! newline)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (line); free (line);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
line = newline; line = newline;
linelen = newlen; linelen = newlen;
@ -1070,7 +1070,7 @@ uiserver_encrypt (void *engine, gpgme_key_t recp[], gpgme_encrypt_flags_t flags,
if (asprintf (&cmd, "PREP_ENCRYPT%s%s", protocol, if (asprintf (&cmd, "PREP_ENCRYPT%s%s", protocol,
(flags & GPGME_ENCRYPT_EXPECT_SIGN) (flags & GPGME_ENCRYPT_EXPECT_SIGN)
? " --expect-sign" : "") < 0) ? " --expect-sign" : "") < 0)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
else else
{ {
@ -1078,7 +1078,7 @@ uiserver_encrypt (void *engine, gpgme_key_t recp[], gpgme_encrypt_flags_t flags,
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
if (asprintf (&cmd, "ENCRYPT%s", protocol) < 0) if (asprintf (&cmd, "ENCRYPT%s", protocol) < 0)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
if (plain) if (plain)
@ -1147,7 +1147,7 @@ uiserver_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
if (asprintf (&cmd, "SIGN%s%s", protocol, if (asprintf (&cmd, "SIGN%s%s", protocol,
(mode == GPGME_SIG_MODE_DETACH) ? " --detached" : "") < 0) (mode == GPGME_SIG_MODE_DETACH) ? " --detached" : "") < 0)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
key = gpgme_signers_enum (ctx, 0); key = gpgme_signers_enum (ctx, 0);
if (key) if (key)
@ -1222,7 +1222,7 @@ uiserver_verify (void *engine, gpgme_data_t sig, gpgme_data_t signed_text,
return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL); return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
if (asprintf (&cmd, "VERIFY%s", protocol) < 0) if (asprintf (&cmd, "VERIFY%s", protocol) < 0)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
uiserver->input_cb.data = sig; uiserver->input_cb.data = sig;
err = uiserver_set_fd (uiserver, INPUT_FD, err = uiserver_set_fd (uiserver, INPUT_FD,

View File

@ -226,7 +226,7 @@ gpgme_get_engine_info (gpgme_engine_info_t *info)
*lastp = malloc (sizeof (*engine_info)); *lastp = malloc (sizeof (*engine_info));
if (!*lastp || !file_name) if (!*lastp || !file_name)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
_gpgme_engine_info_release (engine_info); _gpgme_engine_info_release (engine_info);
engine_info = NULL; engine_info = NULL;
@ -237,7 +237,7 @@ gpgme_get_engine_info (gpgme_engine_info_t *info)
free (home_dir); free (home_dir);
UNLOCK (engine_info_lock); UNLOCK (engine_info_lock);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
(*lastp)->protocol = proto_list[proto]; (*lastp)->protocol = proto_list[proto];
@ -294,7 +294,7 @@ _gpgme_engine_info_copy (gpgme_engine_info_t *r_info)
{ {
home_dir = strdup (info->home_dir); home_dir = strdup (info->home_dir);
if (!home_dir) if (!home_dir)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
} }
else else
home_dir = NULL; home_dir = NULL;
@ -303,7 +303,7 @@ _gpgme_engine_info_copy (gpgme_engine_info_t *r_info)
{ {
version = strdup (info->version); version = strdup (info->version);
if (!version) if (!version)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
} }
else else
version = NULL; version = NULL;
@ -311,7 +311,7 @@ _gpgme_engine_info_copy (gpgme_engine_info_t *r_info)
*lastp = malloc (sizeof (*engine_info)); *lastp = malloc (sizeof (*engine_info));
if (!*lastp || !file_name || err) if (!*lastp || !file_name || err)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
_gpgme_engine_info_release (new_info); _gpgme_engine_info_release (new_info);
@ -323,7 +323,7 @@ _gpgme_engine_info_copy (gpgme_engine_info_t *r_info)
free (version); free (version);
UNLOCK (engine_info_lock); UNLOCK (engine_info_lock);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
(*lastp)->protocol = info->protocol; (*lastp)->protocol = info->protocol;
@ -372,7 +372,7 @@ _gpgme_set_engine_info (gpgme_engine_info_t info, gpgme_protocol_t proto,
new_file_name = strdup (ofile_name); new_file_name = strdup (ofile_name);
} }
if (!new_file_name) if (!new_file_name)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
if (home_dir) if (home_dir)
{ {
@ -380,7 +380,7 @@ _gpgme_set_engine_info (gpgme_engine_info_t info, gpgme_protocol_t proto,
if (!new_home_dir) if (!new_home_dir)
{ {
free (new_file_name); free (new_file_name);
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
} }
else else
@ -392,7 +392,7 @@ _gpgme_set_engine_info (gpgme_engine_info_t info, gpgme_protocol_t proto,
if (!new_home_dir) if (!new_home_dir)
{ {
free (new_file_name); free (new_file_name);
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
} }
else else
@ -454,7 +454,7 @@ _gpgme_engine_new (gpgme_engine_info_t info, engine_t *r_engine)
engine = calloc (1, sizeof *engine); engine = calloc (1, sizeof *engine);
if (!engine) if (!engine)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
engine->ops = engine_ops[info->protocol]; engine->ops = engine_ops[info->protocol];
if (engine->ops->new) if (engine->ops->new)

View File

@ -113,7 +113,7 @@ genkey_status_handler (void *priv, gpgme_status_code_t code, char *args)
free (opd->result.fpr); free (opd->result.fpr);
opd->result.fpr = strdup (&args[2]); opd->result.fpr = strdup (&args[2]);
if (!opd->result.fpr) if (!opd->result.fpr)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
} }
break; break;

View File

@ -46,7 +46,7 @@ _gpgme_getenv (const char *name, char **value)
{ {
*value = strdup (env_value); *value = strdup (env_value);
if (!*value) if (!*value)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
return 0; return 0;
} }

View File

@ -1614,7 +1614,7 @@ gt_recipients_add (gpgme_tool_t gt, const char *pattern)
gpgme_key_t key; gpgme_key_t key;
if (gt->recipients_nr >= MAX_RECIPIENTS) if (gt->recipients_nr >= MAX_RECIPIENTS)
return gpg_error_from_errno (ENOMEM); return gpg_error (GPG_ERR_ENOMEM);
if (gpgme_get_protocol (gt->ctx) == GPGME_PROTOCOL_UISERVER) if (gpgme_get_protocol (gt->ctx) == GPGME_PROTOCOL_UISERVER)
err = gpgme_key_from_uid (&key, pattern); err = gpgme_key_from_uid (&key, pattern);

View File

@ -87,7 +87,7 @@ gpgme_new (gpgme_ctx_t *r_ctx)
ctx = calloc (1, sizeof *ctx); ctx = calloc (1, sizeof *ctx);
if (!ctx) if (!ctx)
return TRACE_ERR (gpg_error_from_errno (errno)); return TRACE_ERR (gpg_error_from_syserror ());
INIT_LOCK (ctx->lock); INIT_LOCK (ctx->lock);
@ -95,7 +95,7 @@ gpgme_new (gpgme_ctx_t *r_ctx)
if (!ctx->engine_info) if (!ctx->engine_info)
{ {
free (ctx); free (ctx);
return TRACE_ERR (gpg_error_from_errno (errno)); return TRACE_ERR (gpg_error_from_syserror ());
} }
ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL; ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL;
@ -110,10 +110,11 @@ gpgme_new (gpgme_ctx_t *r_ctx)
ctx->lc_ctype = strdup (def_lc_ctype); ctx->lc_ctype = strdup (def_lc_ctype);
if (!ctx->lc_ctype) if (!ctx->lc_ctype)
{ {
int saved_err = gpg_error_from_syserror ();
UNLOCK (def_lc_lock); UNLOCK (def_lc_lock);
_gpgme_engine_info_release (ctx->engine_info); _gpgme_engine_info_release (ctx->engine_info);
free (ctx); free (ctx);
return TRACE_ERR (gpg_error_from_errno (errno)); return TRACE_ERR (saved_err);
} }
} }
else else
@ -124,12 +125,13 @@ gpgme_new (gpgme_ctx_t *r_ctx)
ctx->lc_messages = strdup (def_lc_messages); ctx->lc_messages = strdup (def_lc_messages);
if (!ctx->lc_messages) if (!ctx->lc_messages)
{ {
int saved_err = gpg_error_from_syserror ();
UNLOCK (def_lc_lock); UNLOCK (def_lc_lock);
if (ctx->lc_ctype) if (ctx->lc_ctype)
free (ctx->lc_ctype); free (ctx->lc_ctype);
_gpgme_engine_info_release (ctx->engine_info); _gpgme_engine_info_release (ctx->engine_info);
free (ctx); free (ctx);
return TRACE_ERR (gpg_error_from_errno (errno)); return TRACE_ERR (saved_err);
} }
} }
else else
@ -676,14 +678,14 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
if (failed) if (failed)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
if (new_lc_ctype) if (new_lc_ctype)
free (new_lc_ctype); free (new_lc_ctype);
if (new_lc_messages) if (new_lc_messages)
free (new_lc_messages); free (new_lc_messages);
return TRACE_ERR (gpg_error_from_errno (saved_errno)); return TRACE_ERR (saved_err);
} }
#define SET_ONE_LOCALE(lcat, ucat) \ #define SET_ONE_LOCALE(lcat, ucat) \

View File

@ -174,9 +174,8 @@ parse_import (char *args, gpgme_import_status_t *import_status, int problem)
import->fpr = strdup (args); import->fpr = strdup (args);
if (!import->fpr) if (!import->fpr)
{ {
int saved_errno = errno;
free (import); free (import);
return gpg_error_from_errno (saved_errno); return gpg_error_from_syserror ();
} }
*import_status = import; *import_status = import;

View File

@ -46,7 +46,7 @@ _gpgme_key_new (gpgme_key_t *r_key)
key = calloc (1, sizeof *key); key = calloc (1, sizeof *key);
if (!key) if (!key)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
key->_refs = 1; key->_refs = 1;
*r_key = key; *r_key = key;
@ -61,7 +61,7 @@ _gpgme_key_add_subkey (gpgme_key_t key, gpgme_subkey_t *r_subkey)
subkey = calloc (1, sizeof *subkey); subkey = calloc (1, sizeof *subkey);
if (!subkey) if (!subkey)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
subkey->keyid = subkey->_keyid; subkey->keyid = subkey->_keyid;
subkey->_keyid[16] = '\0'; subkey->_keyid[16] = '\0';
@ -215,7 +215,7 @@ _gpgme_key_append_name (gpgme_key_t key, const char *src, int convert)
size, so that we are able to store the parsed stuff there too. */ size, so that we are able to store the parsed stuff there too. */
uid = malloc (sizeof (*uid) + 2 * src_len + 3); uid = malloc (sizeof (*uid) + 2 * src_len + 3);
if (!uid) if (!uid)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
memset (uid, 0, sizeof *uid); memset (uid, 0, sizeof *uid);
uid->uid = ((char *) uid) + sizeof (*uid); uid->uid = ((char *) uid) + sizeof (*uid);

View File

@ -558,7 +558,7 @@ keylist_colon_handler (void *priv, char *line)
{ {
key->issuer_serial = strdup (field[7]); key->issuer_serial = strdup (field[7]);
if (!key->issuer_serial) if (!key->issuer_serial)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
/* Field 9 has the ownertrust. */ /* Field 9 has the ownertrust. */
@ -653,7 +653,7 @@ keylist_colon_handler (void *priv, char *line)
if (fields >= 10) if (fields >= 10)
{ {
if (_gpgme_key_append_name (key, field[9], 1)) if (_gpgme_key_append_name (key, field[9], 1))
return gpg_error_from_errno (GPG_ERR_ENOMEM); /* FIXME */ return gpg_error (GPG_ERR_ENOMEM); /* FIXME */
else else
{ {
if (field[1]) if (field[1])
@ -674,7 +674,7 @@ keylist_colon_handler (void *priv, char *line)
{ {
subkey->fpr = strdup (field[9]); subkey->fpr = strdup (field[9]);
if (!subkey->fpr) if (!subkey->fpr)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
} }
@ -683,7 +683,7 @@ keylist_colon_handler (void *priv, char *line)
{ {
key->chain_id = strdup (field[12]); key->chain_id = strdup (field[12]);
if (!key->chain_id) if (!key->chain_id)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
break; break;

View File

@ -56,7 +56,7 @@ _gpgme_op_data_lookup (gpgme_ctx_t ctx, ctx_op_data_id_t type, void **hook,
data = calloc (1, sizeof (struct ctx_op_data) + size); data = calloc (1, sizeof (struct ctx_op_data) + size);
if (!data) if (!data)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
data->magic = CTX_OP_DATA_MAGIC; data->magic = CTX_OP_DATA_MAGIC;
data->next = ctx->op_data; data->next = ctx->op_data;
data->type = type; data->type = type;
@ -192,7 +192,7 @@ _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key)
inv_key = malloc (sizeof (*inv_key)); inv_key = malloc (sizeof (*inv_key));
if (!inv_key) if (!inv_key)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
inv_key->next = NULL; inv_key->next = NULL;
gpg_err_set_errno (0); gpg_err_set_errno (0);
reason = strtol (args, &tail, 0); reason = strtol (args, &tail, 0);
@ -266,9 +266,8 @@ _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key)
inv_key->fpr = strdup (tail); inv_key->fpr = strdup (tail);
if (!inv_key->fpr) if (!inv_key->fpr)
{ {
int saved_errno = errno;
free (inv_key); free (inv_key);
return gpg_error_from_errno (saved_errno); return gpg_error_from_syserror ();
} }
} }
else else

View File

@ -77,7 +77,7 @@ _gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code,
if (opd->uid_hint) if (opd->uid_hint)
free (opd->uid_hint); free (opd->uid_hint);
if (!(opd->uid_hint = strdup (args))) if (!(opd->uid_hint = strdup (args)))
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
break; break;
case GPGME_STATUS_BAD_PASSPHRASE: case GPGME_STATUS_BAD_PASSPHRASE:
@ -97,7 +97,7 @@ _gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code,
free (opd->passphrase_info); free (opd->passphrase_info);
opd->passphrase_info = strdup (args); opd->passphrase_info = strdup (args);
if (!opd->passphrase_info) if (!opd->passphrase_info)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
break; break;
case GPGME_STATUS_MISSING_PASSPHRASE: case GPGME_STATUS_MISSING_PASSPHRASE:

View File

@ -47,7 +47,7 @@ _gpgme_progress_status_handler (void *priv, gpgme_status_code_t code,
args_cpy = strdup (args); args_cpy = strdup (args);
if (!args_cpy) if (!args_cpy)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
p = strchr (args_cpy, ' '); p = strchr (args_cpy, ' ');
if (p) if (p)

View File

@ -79,7 +79,7 @@ _gpgme_sig_notation_create (gpgme_sig_notation_t *notationp,
notation = calloc (1, sizeof (*notation)); notation = calloc (1, sizeof (*notation));
if (!notation) if (!notation)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
/* This is critical. We want to reliably identify policy URLs by /* This is critical. We want to reliably identify policy URLs by
using a NULL pointer for NAME. So all notations must have a NAME using a NULL pointer for NAME. So all notations must have a NAME
@ -91,7 +91,7 @@ _gpgme_sig_notation_create (gpgme_sig_notation_t *notationp,
notation->name = malloc (name_len + 1); notation->name = malloc (name_len + 1);
if (!notation->name) if (!notation->name)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto err; goto err;
} }
@ -107,7 +107,7 @@ _gpgme_sig_notation_create (gpgme_sig_notation_t *notationp,
notation->value = malloc (value_len + 1); notation->value = malloc (value_len + 1);
if (!notation->value) if (!notation->value)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto err; goto err;
} }

View File

@ -234,9 +234,8 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
sig->fpr = strdup (args); sig->fpr = strdup (args);
if (!sig->fpr) if (!sig->fpr)
{ {
int saved_errno = errno;
free (sig); free (sig);
return gpg_error_from_errno (saved_errno); return gpg_error_from_syserror ();
} }
*sigp = sig; *sigp = sig;
return 0; return 0;

View File

@ -80,7 +80,7 @@ gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key)
newarr = realloc (ctx->signers, n * sizeof (*newarr)); newarr = realloc (ctx->signers, n * sizeof (*newarr));
if (!newarr) if (!newarr)
return TRACE_ERR (gpg_error_from_errno (errno)); return TRACE_ERR (gpg_error_from_syserror ());
for (j = ctx->signers_size; j < n; j++) for (j = ctx->signers_size; j < n; j++)
newarr[j] = NULL; newarr[j] = NULL;
ctx->signers = newarr; ctx->signers = newarr;

View File

@ -47,7 +47,7 @@ _gpgme_trust_item_new (gpgme_trust_item_t *r_item)
item = calloc (1, sizeof *item); item = calloc (1, sizeof *item);
if (!item) if (!item)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
item->_refs = 1; item->_refs = 1;
item->keyid = item->_keyid; item->keyid = item->_keyid;
item->_keyid[16] = '\0'; item->_keyid[16] = '\0';

View File

@ -111,9 +111,9 @@ trustlist_colon_handler (void *priv, char *line)
item->name = strdup (p); item->name = strdup (p);
if (!item->name) if (!item->name)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
gpgme_trust_item_unref (item); gpgme_trust_item_unref (item);
return gpg_error_from_errno (saved_errno); return saved_err;
} }
break; break;
} }

View File

@ -97,7 +97,7 @@ ctx_active (gpgme_ctx_t ctx)
{ {
struct ctx_list_item *li = malloc (sizeof (struct ctx_list_item)); struct ctx_list_item *li = malloc (sizeof (struct ctx_list_item));
if (!li) if (!li)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
li->ctx = ctx; li->ctx = ctx;
LOCK (ctx_list_lock); LOCK (ctx_list_lock);
@ -269,10 +269,10 @@ gpgme_wait_ext (gpgme_ctx_t ctx, gpgme_error_t *status,
fdt.fds = malloc (i * sizeof (struct io_select_fd_s)); fdt.fds = malloc (i * sizeof (struct io_select_fd_s));
if (!fdt.fds) if (!fdt.fds)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
UNLOCK (ctx_list_lock); UNLOCK (ctx_list_lock);
if (status) if (status)
*status = gpg_error_from_errno (saved_errno); *status = saved_err;
if (op_err) if (op_err)
*op_err = 0; *op_err = 0;
return NULL; return NULL;
@ -290,10 +290,10 @@ gpgme_wait_ext (gpgme_ctx_t ctx, gpgme_error_t *status,
nr = _gpgme_io_select (fdt.fds, fdt.size, 0); nr = _gpgme_io_select (fdt.fds, fdt.size, 0);
if (nr < 0) if (nr < 0)
{ {
int saved_errno = errno; int saved_err = gpg_error_from_syserror ();
free (fdt.fds); free (fdt.fds);
if (status) if (status)
*status = gpg_error_from_errno (saved_errno); *status = saved_err;
if (op_err) if (op_err)
*op_err = 0; *op_err = 0;
return NULL; return NULL;

View File

@ -91,7 +91,7 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond,
{ {
/* An error occured. Close all fds in this context, and /* An error occured. Close all fds in this context, and
signal it. */ signal it. */
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
_gpgme_cancel_with_err (ctx, err, 0); _gpgme_cancel_with_err (ctx, err, 0);
return err; return err;

View File

@ -73,7 +73,7 @@ fd_table_put (fd_table_t fdt, int fd, int dir, void *opaque, int *idx)
new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE) new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE)
* sizeof (*new_fds)); * sizeof (*new_fds));
if (!new_fds) if (!new_fds)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
fdt->fds = new_fds; fdt->fds = new_fds;
fdt->size += FDT_ALLOCSIZE; fdt->size += FDT_ALLOCSIZE;
@ -113,16 +113,15 @@ _gpgme_add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc,
tag = malloc (sizeof *tag); tag = malloc (sizeof *tag);
if (!tag) if (!tag)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
tag->ctx = ctx; tag->ctx = ctx;
/* Allocate a structure to hold information about the handler. */ /* Allocate a structure to hold information about the handler. */
item = calloc (1, sizeof *item); item = calloc (1, sizeof *item);
if (!item) if (!item)
{ {
int saved_errno = errno;
free (tag); free (tag);
return gpg_error_from_errno (saved_errno); return gpg_error_from_syserror ();
} }
item->ctx = ctx; item->ctx = ctx;
item->dir = dir; item->dir = dir;