core: Minor cleanup in engine-gpg and -gpgsm.

* src/engine-gpg.c: Remove errno.h.
(build_argv): Use gpg_error_from_syserror instead of ERRNO.
* src/engine-gpgsm.c: Remove errno.h.
(status_handler): Remove check for EINTR; gpgme_data_write already
handles EINTR.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-05-31 23:56:06 +02:00
parent 618aa7f08d
commit 2219fc19d5
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 3 additions and 6 deletions

View File

@ -26,7 +26,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#endif #endif
@ -1039,10 +1038,10 @@ build_argv (engine_gpg_t gpg, const char *pgmname)
if (_gpgme_io_pipe (fds, fd_data_map[datac].inbound ? 1 : 0) if (_gpgme_io_pipe (fds, fd_data_map[datac].inbound ? 1 : 0)
== -1) == -1)
{ {
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 (saved_errno); return saved_err;
} }
if (_gpgme_io_set_close_notify (fds[0], if (_gpgme_io_set_close_notify (fds[0],
close_notify_handler, gpg) close_notify_handler, gpg)

View File

@ -37,7 +37,6 @@
#include <locale.h> #include <locale.h>
#endif #endif
#include <fcntl.h> /* FIXME */ #include <fcntl.h> /* FIXME */
#include <errno.h>
#include "gpgme.h" #include "gpgme.h"
#include "util.h" #include "util.h"
@ -986,8 +985,7 @@ status_handler (void *opaque, int fd)
while (linelen > 0) while (linelen > 0)
{ {
nwritten = gpgme_data_write (gpgsm->inline_data, src, linelen); nwritten = gpgme_data_write (gpgsm->inline_data, src, linelen);
if (!nwritten || (nwritten < 0 && errno != EINTR) if (nwritten <= 0 || nwritten > linelen)
|| nwritten > linelen)
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
break; break;