if (fname)
stream = fopen (fname, "rb");
if (!stream)
- return TRACE_ERR (gpg_error_from_errno (errno));
+ return TRACE_ERR (gpg_error_from_syserror ());
#ifdef HAVE_FSEEKO
res = fseeko (stream, offset, SEEK_SET);
if (res)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
if (fname)
fclose (stream);
- return TRACE_ERR (gpg_error_from_errno (saved_errno));
+ return TRACE_ERR (saved_err);
}
buf = malloc (length);
if (!buf)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
if (fname)
fclose (stream);
- return TRACE_ERR (gpg_error_from_errno (saved_errno));
+ return TRACE_ERR (saved_err);
}
while (fread (buf, length, 1, stream) < 1
&& ferror (stream) && errno == EINTR);
if (ferror (stream))
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
if (buf)
free (buf);
if (fname)
fclose (stream);
- return TRACE_ERR (gpg_error_from_errno (saved_errno));
+ return TRACE_ERR (saved_err);
}
if (fname)
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
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);
return TRACE_ERR (err);
gpgme_error_t err;
TRACE_BEG (DEBUG_DATA, "gpgme_data_rewind", dh);
- err = (gpgme_data_seek (dh, 0, SEEK_SET) == -1)
- ? gpg_error_from_errno (errno) : 0;
+ err = ((gpgme_data_seek (dh, 0, SEEK_SET) == -1)
+ ? gpg_error_from_syserror () : 0);
return TRACE_ERR (err);
}
char *bufcpy = malloc (size);
if (!bufcpy)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
_gpgme_data_release (*r_dh);
- return TRACE_ERR (gpg_error_from_errno (saved_errno));
+ return TRACE_ERR (saved_err);
}
memcpy (bufcpy, buffer, size);
(*r_dh)->data.mem.buffer = bufcpy;
str = malloc (dh->data.mem.length);
if (!str)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
gpgme_data_release (dh);
- TRACE_ERR (gpg_error_from_errno (saved_errno));
+ TRACE_ERR (saved_err);
return NULL;
}
memcpy (str, dh->data.mem.orig_buffer, dh->data.mem.length);
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 (llass->assuan_ctx, optstr, NULL, NULL,
g13 = calloc (1, sizeof *g13);
if (!g13)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
g13->status_cb.fd = -1;
g13->status_cb.dir = 1;
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);
{
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 (g13->assuan_ctx, optstr, NULL, NULL, NULL,
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);
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 (g13->assuan_ctx, optstr, NULL, NULL,
a = malloc (sizeof *a + strlen (arg));
if (!a)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
a->data = NULL;
a->dup_to = -1;
a = malloc (sizeof *a - 1);
if (!a)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
a->next = NULL;
a->data = data;
a->inbound = inbound;
gpg = calloc (1, sizeof *gpg);
if (!gpg)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
if (file_name)
{
gpg->file_name = strdup (file_name);
if (!gpg->file_name)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
goto leave;
}
}
gpg->status.buffer = malloc (gpg->status.bufsize);
if (!gpg->status.buffer)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
goto leave;
}
/* In any case we need a status pipe - create it right here and
don't handle it with our generic gpgme_data_t mechanism. */
if (_gpgme_io_pipe (gpg->status.fd, 1) == -1)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
goto leave;
}
if (_gpgme_io_set_close_notify (gpg->status.fd[0],
gpg->colon.readpos = 0;
gpg->colon.buffer = malloc (gpg->colon.bufsize);
if (!gpg->colon.buffer)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
if (_gpgme_io_pipe (gpg->colon.fd, 1) == -1)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (gpg->colon.buffer);
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)
|| _gpgme_io_set_close_notify (gpg->colon.fd[1],
argv = calloc (argc + 1, sizeof *argv);
if (!argv)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
fd_data_map = calloc (datac + 1, sizeof *fd_data_map);
if (!fd_data_map)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free_argv (argv);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
argc = datac = 0;
argv[argc] = strdup ("gpg"); /* argv[0] */
if (!argv[argc])
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (fd_data_map);
free_argv (argv);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
argc++;
if (need_special)
argv[argc] = strdup ("--enable-special-filenames");
if (!argv[argc])
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (fd_data_map);
free_argv (argv);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
argc++;
}
argv[argc] = strdup ("--use-agent");
if (!argv[argc])
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (fd_data_map);
free_argv (argv);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
argc++;
}
argv[argc] = strdup ("--batch");
if (!argv[argc])
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (fd_data_map);
free_argv (argv);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
argc++;
}
argv[argc] = strdup ("--no-sk-comment");
if (!argv[argc])
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (fd_data_map);
free_argv (argv);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
argc++;
for (a = gpg->arglist; a; a = a->next)
argv[argc] = malloc (buflen);
if (!argv[argc])
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (fd_data_map);
free_argv (argv);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
ptr = argv[argc];
argv[argc] = strdup (a->arg);
if (!argv[argc])
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (fd_data_map);
free_argv (argv);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
argc++;
}
bufsize += 1024;
buffer = realloc (buffer, bufsize);
if (!buffer)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
nread = _gpgme_io_read (gpg->status.fd[0],
buffer + readpos, bufsize-readpos);
if (nread == -1)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
if (!nread)
{
free (gpg->cmd.keyword);
gpg->cmd.keyword = strdup (rest);
if (!gpg->cmd.keyword)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
/* This should be the last thing we have
received and the next thing will be that
the command handler does its action. */
bufsize += 1024;
buffer = realloc (buffer, bufsize);
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);
if (nread == -1)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
if (!nread)
{
start (engine_gpg_t gpg)
{
gpgme_error_t rc;
- int saved_errno;
int i, n;
int status;
struct spawn_fd_item_s *fd_list;
n++;
fd_list = calloc (n, sizeof *fd_list);
if (! fd_list)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
/* Build the fd list for the child. */
n = 0;
_gpgme_get_gpg_path (), gpg->argv,
IOSPAWN_FLAG_ALLOW_SET_FG,
fd_list, NULL, NULL, &pid);
- saved_errno = errno;
-
- free (fd_list);
- if (status == -1)
- return gpg_error_from_errno (saved_errno);
+ {
+ int saved_err = gpg_error_from_syserror ();
+ free (fd_list);
+ if (status == -1)
+ return saved_err;
+ }
/*_gpgme_register_term_handler ( closure, closure_value, pid );*/
arg = malloc (1 + notation->name_len + 1 + notation->value_len + 1);
if (!arg)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
if (!err)
{
{
value = malloc (1 + notation->value_len + 1);
if (!value)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
{
value[0] = '!';
if (asprintf (r_line, "pub:o%s:%s:%s:%s:%s:%s::::::::",
field[6], field[3], field[2], field[1],
field[4], field[5]) < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
return 0;
case RT_UID:
char *dst;
if (! uid)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
src = field[1];
dst = uid;
while (*src)
if (asprintf (r_line, "uid:o%s::::%s:%s:::%s:",
field[4], field[2], field[3], uid) < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
return 0;
gpgconf = calloc (1, sizeof *gpgconf);
if (!gpgconf)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
gpgconf->file_name = strdup (file_name ? file_name
: _gpgme_get_gpgconf_path ());
char *newline = realloc (line, newlen);
if (! newline)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (line);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
line = newline;
linelen = newlen;
{
if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
{
+ err = gpg_error_from_syserror ();
free (dft_display);
- err = gpg_error_from_errno (errno);
goto leave;
}
free (dft_display);
{
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 (uiserver->assuan_ctx, optstr, NULL, NULL, NULL,
{
if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
{
+ err = gpg_error_from_syserror ();
free (dft_ttytype);
- err = gpg_error_from_errno (errno);
goto leave;
}
free (dft_ttytype);
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 (uiserver->assuan_ctx, optstr, NULL, NULL,
int fds[2];
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->server_fd = dir ? fds[1] : fds[0];
{
char *newline = realloc (*aline, *alinelen + linelen + 1);
if (!newline)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
{
*aline = newline;
if (!nwritten || (nwritten < 0 && errno != EINTR)
|| nwritten > linelen)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
break;
}
src += nwritten;
if (asprintf (&cmd, "DECRYPT%s%s", protocol,
verify ? "" : " --no-verify") < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
uiserver->input_cb.data = ciph;
err = uiserver_set_fd (uiserver, INPUT_FD,
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++)
{
char *newline = realloc (line, newlen);
if (! newline)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (line);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
line = newline;
linelen = newlen;
if (asprintf (&cmd, "PREP_ENCRYPT%s%s", protocol,
(flags & GPGME_ENCRYPT_EXPECT_SIGN)
? " --expect-sign" : "") < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
else
{
return gpg_error (GPG_ERR_INV_VALUE);
if (asprintf (&cmd, "ENCRYPT%s", protocol) < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
if (plain)
if (asprintf (&cmd, "SIGN%s%s", protocol,
(mode == GPGME_SIG_MODE_DETACH) ? " --detached" : "") < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
key = gpgme_signers_enum (ctx, 0);
if (key)
return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
if (asprintf (&cmd, "VERIFY%s", protocol) < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
uiserver->input_cb.data = sig;
err = uiserver_set_fd (uiserver, INPUT_FD,
*lastp = malloc (sizeof (*engine_info));
if (!*lastp || !file_name)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
_gpgme_engine_info_release (engine_info);
engine_info = NULL;
free (home_dir);
UNLOCK (engine_info_lock);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
(*lastp)->protocol = proto_list[proto];
{
home_dir = strdup (info->home_dir);
if (!home_dir)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
}
else
home_dir = NULL;
{
version = strdup (info->version);
if (!version)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
}
else
version = NULL;
*lastp = malloc (sizeof (*engine_info));
if (!*lastp || !file_name || err)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
_gpgme_engine_info_release (new_info);
free (version);
UNLOCK (engine_info_lock);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
(*lastp)->protocol = info->protocol;
new_file_name = strdup (ofile_name);
}
if (!new_file_name)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
if (home_dir)
{
if (!new_home_dir)
{
free (new_file_name);
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
}
else
if (!new_home_dir)
{
free (new_file_name);
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
}
else
engine = calloc (1, sizeof *engine);
if (!engine)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
engine->ops = engine_ops[info->protocol];
if (engine->ops->new)
free (opd->result.fpr);
opd->result.fpr = strdup (&args[2]);
if (!opd->result.fpr)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
}
break;
{
*value = strdup (env_value);
if (!*value)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
return 0;
}
gpgme_key_t key;
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)
err = gpgme_key_from_uid (&key, pattern);
ctx = calloc (1, sizeof *ctx);
if (!ctx)
- return TRACE_ERR (gpg_error_from_errno (errno));
+ return TRACE_ERR (gpg_error_from_syserror ());
INIT_LOCK (ctx->lock);
if (!ctx->engine_info)
{
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->lc_ctype = strdup (def_lc_ctype);
if (!ctx->lc_ctype)
{
+ int saved_err = gpg_error_from_syserror ();
UNLOCK (def_lc_lock);
_gpgme_engine_info_release (ctx->engine_info);
free (ctx);
- return TRACE_ERR (gpg_error_from_errno (errno));
+ return TRACE_ERR (saved_err);
}
}
else
ctx->lc_messages = strdup (def_lc_messages);
if (!ctx->lc_messages)
{
+ int saved_err = gpg_error_from_syserror ();
UNLOCK (def_lc_lock);
if (ctx->lc_ctype)
free (ctx->lc_ctype);
_gpgme_engine_info_release (ctx->engine_info);
free (ctx);
- return TRACE_ERR (gpg_error_from_errno (errno));
+ return TRACE_ERR (saved_err);
}
}
else
if (failed)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
if (new_lc_ctype)
free (new_lc_ctype);
if (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) \
import->fpr = strdup (args);
if (!import->fpr)
{
- int saved_errno = errno;
free (import);
- return gpg_error_from_errno (saved_errno);
+ return gpg_error_from_syserror ();
}
*import_status = import;
key = calloc (1, sizeof *key);
if (!key)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
key->_refs = 1;
*r_key = key;
subkey = calloc (1, sizeof *subkey);
if (!subkey)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
subkey->keyid = subkey->_keyid;
subkey->_keyid[16] = '\0';
size, so that we are able to store the parsed stuff there too. */
uid = malloc (sizeof (*uid) + 2 * src_len + 3);
if (!uid)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
memset (uid, 0, sizeof *uid);
uid->uid = ((char *) uid) + sizeof (*uid);
{
key->issuer_serial = strdup (field[7]);
if (!key->issuer_serial)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
/* Field 9 has the ownertrust. */
if (fields >= 10)
{
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
{
if (field[1])
{
subkey->fpr = strdup (field[9]);
if (!subkey->fpr)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
}
{
key->chain_id = strdup (field[12]);
if (!key->chain_id)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
break;
data = calloc (1, sizeof (struct ctx_op_data) + size);
if (!data)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
data->magic = CTX_OP_DATA_MAGIC;
data->next = ctx->op_data;
data->type = type;
inv_key = malloc (sizeof (*inv_key));
if (!inv_key)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
inv_key->next = NULL;
gpg_err_set_errno (0);
reason = strtol (args, &tail, 0);
inv_key->fpr = strdup (tail);
if (!inv_key->fpr)
{
- int saved_errno = errno;
free (inv_key);
- return gpg_error_from_errno (saved_errno);
+ return gpg_error_from_syserror ();
}
}
else
if (opd->uid_hint)
free (opd->uid_hint);
if (!(opd->uid_hint = strdup (args)))
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
break;
case GPGME_STATUS_BAD_PASSPHRASE:
free (opd->passphrase_info);
opd->passphrase_info = strdup (args);
if (!opd->passphrase_info)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
break;
case GPGME_STATUS_MISSING_PASSPHRASE:
args_cpy = strdup (args);
if (!args_cpy)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
p = strchr (args_cpy, ' ');
if (p)
notation = calloc (1, sizeof (*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
using a NULL pointer for NAME. So all notations must have a NAME
notation->name = malloc (name_len + 1);
if (!notation->name)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto err;
}
notation->value = malloc (value_len + 1);
if (!notation->value)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto err;
}
sig->fpr = strdup (args);
if (!sig->fpr)
{
- int saved_errno = errno;
free (sig);
- return gpg_error_from_errno (saved_errno);
+ return gpg_error_from_syserror ();
}
*sigp = sig;
return 0;
newarr = realloc (ctx->signers, n * sizeof (*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++)
newarr[j] = NULL;
ctx->signers = newarr;
item = calloc (1, sizeof *item);
if (!item)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
item->_refs = 1;
item->keyid = item->_keyid;
item->_keyid[16] = '\0';
item->name = strdup (p);
if (!item->name)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
gpgme_trust_item_unref (item);
- return gpg_error_from_errno (saved_errno);
+ return saved_err;
}
break;
}
{
struct ctx_list_item *li = malloc (sizeof (struct ctx_list_item));
if (!li)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
li->ctx = ctx;
LOCK (ctx_list_lock);
fdt.fds = malloc (i * sizeof (struct io_select_fd_s));
if (!fdt.fds)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
UNLOCK (ctx_list_lock);
if (status)
- *status = gpg_error_from_errno (saved_errno);
+ *status = saved_err;
if (op_err)
*op_err = 0;
return NULL;
nr = _gpgme_io_select (fdt.fds, fdt.size, 0);
if (nr < 0)
{
- int saved_errno = errno;
+ int saved_err = gpg_error_from_syserror ();
free (fdt.fds);
if (status)
- *status = gpg_error_from_errno (saved_errno);
+ *status = saved_err;
if (op_err)
*op_err = 0;
return NULL;
{
/* An error occured. Close all fds in this context, and
signal it. */
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
_gpgme_cancel_with_err (ctx, err, 0);
return err;
new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE)
* sizeof (*new_fds));
if (!new_fds)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
fdt->fds = new_fds;
fdt->size += FDT_ALLOCSIZE;
tag = malloc (sizeof *tag);
if (!tag)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
tag->ctx = ctx;
/* Allocate a structure to hold information about the handler. */
item = calloc (1, sizeof *item);
if (!item)
{
- int saved_errno = errno;
free (tag);
- return gpg_error_from_errno (saved_errno);
+ return gpg_error_from_syserror ();
}
item->ctx = ctx;
item->dir = dir;