aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/assuan-buffer.c2
-rw-r--r--src/assuan-handler.c2
-rw-r--r--src/assuan-logging.c2
-rw-r--r--src/assuan-socket.c34
-rw-r--r--src/assuan-uds.c4
-rw-r--r--src/debug.c2
-rw-r--r--src/system.c38
8 files changed, 49 insertions, 42 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 33df124..d7df666 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2010-01-22 Werner Koch <[email protected]>
+
+ * assuan-socket.c (read_port_and_nonce): Replace ENOFILE by a
+ proper ENOENT.
+
+ Replace all assignments to ERRNO by a call to gpg_err_set_errno.
+
2010-01-14 Werner Koch <[email protected]>
* debug.c (_assuan_debug, _assuan_debug_begin)
diff --git a/src/assuan-buffer.c b/src/assuan-buffer.c
index 1fd394b..db65e66 100644
--- a/src/assuan-buffer.c
+++ b/src/assuan-buffer.c
@@ -155,7 +155,7 @@ _assuan_read_line (assuan_context_t ctx)
ctx->inbound.attic.linelen = atticlen + nread;
}
- errno = saved_errno;
+ gpg_err_set_errno (saved_errno);
return _assuan_error (ctx, gpg_err_code_from_syserror ());
}
if (!nread)
diff --git a/src/assuan-handler.c b/src/assuan-handler.c
index a9cc2bd..f77d59b 100644
--- a/src/assuan-handler.c
+++ b/src/assuan-handler.c
@@ -864,7 +864,7 @@ assuan_get_data_fp (assuan_context_t ctx)
ctx->outbound.data.error = 0;
return ctx->outbound.data.fp;
#else
- errno = ENOSYS;
+ gpg_err_set_errno (ENOSYS);
return NULL;
#endif
}
diff --git a/src/assuan-logging.c b/src/assuan-logging.c
index 5d9d488..13af63a 100644
--- a/src/assuan-logging.c
+++ b/src/assuan-logging.c
@@ -137,7 +137,7 @@ _assuan_log_handler (assuan_context_t ctx, void *hook, unsigned int cat,
with a LF. */
if (msg && *msg && msg[strlen (msg) - 1] == '\n')
fflush (fp);
- errno = saved_errno;
+ gpg_err_set_errno (saved_errno);
return 0;
}
diff --git a/src/assuan-socket.c b/src/assuan-socket.c
index 1d20109..6a8954d 100644
--- a/src/assuan-socket.c
+++ b/src/assuan-socket.c
@@ -89,11 +89,11 @@ get_nonce (char *buffer, size_t nbytes)
if (!CryptAcquireContext (&prov, NULL, NULL, PROV_RSA_FULL,
(CRYPT_VERIFYCONTEXT|CRYPT_SILENT)) )
- errno = ENODEV;
+ gpg_err_set_errno (ENODEV);
else
{
if (!CryptGenRandom (prov, nbytes, (unsigned char *) buffer))
- errno = ENODEV;
+ gpg_err_set_errno (ENODEV);
else
ret = 0;
CryptReleaseContext (prov, 0);
@@ -119,14 +119,14 @@ read_port_and_nonce (const char *fname, unsigned short *port, char *nonce)
fclose (fp);
if (!nread)
{
- errno = ENOFILE;
+ gpg_err_set_errno (ENOENT);
return -1;
}
buffer[nread] = 0;
aval = atoi (buffer);
if (aval < 1 || aval > 65535)
{
- errno = EINVAL;
+ gpg_err_set_errno (EINVAL);
return -1;
}
*port = (unsigned int)aval;
@@ -134,7 +134,7 @@ read_port_and_nonce (const char *fname, unsigned short *port, char *nonce)
;
if (*p != '\n' || nread != 17)
{
- errno = EINVAL;
+ gpg_err_set_errno (EINVAL);
return -1;
}
p++; nread--;
@@ -156,7 +156,7 @@ _assuan_sock_new (assuan_context_t ctx, int domain, int type, int proto)
domain = AF_INET;
res = SOCKET2HANDLE(socket (domain, type, proto));
if (res == ASSUAN_INVALID_FD)
- errno = _assuan_sock_wsa2errno (WSAGetLastError ());
+ gpg_err_set_errno (_assuan_sock_wsa2errno (WSAGetLastError ()));
return res;
#else
return socket (domain, type, proto);
@@ -198,7 +198,7 @@ _assuan_sock_connect (assuan_context_t ctx, assuan_fd_t sockfd,
ret = _assuan_write (ctx, sockfd, nonce, 16);
if (ret >= 0 && ret != 16)
{
- errno = EIO;
+ gpg_err_set_errno (EIO);
ret = -1;
}
}
@@ -209,7 +209,7 @@ _assuan_sock_connect (assuan_context_t ctx, assuan_fd_t sockfd,
int res;
res = connect (HANDLE2SOCKET (sockfd), addr, addrlen);
if (res < 0)
- errno = _assuan_sock_wsa2errno (WSAGetLastError ());
+ gpg_err_set_errno (_assuan_sock_wsa2errno (WSAGetLastError ()));
return res;
}
#else
@@ -248,7 +248,7 @@ _assuan_sock_bind (assuan_context_t ctx, assuan_fd_t sockfd,
if (filefd == -1)
{
if (errno == EEXIST)
- errno = WSAEADDRINUSE;
+ gpg_err_set_errno (WSAEADDRINUSE);
return -1;
}
fp = fdopen (filefd, "wb");
@@ -256,7 +256,7 @@ _assuan_sock_bind (assuan_context_t ctx, assuan_fd_t sockfd,
{
int save_e = errno;
close (filefd);
- errno = save_e;
+ gpg_err_set_errno (save_e);
return -1;
}
@@ -269,7 +269,7 @@ _assuan_sock_bind (assuan_context_t ctx, assuan_fd_t sockfd,
int save_e = errno;
fclose (fp);
remove (unaddr->sun_path);
- errno = save_e;
+ gpg_err_set_errno (save_e);
return rc;
}
fprintf (fp, "%d\n", ntohs (myaddr.sin_port));
@@ -282,7 +282,7 @@ _assuan_sock_bind (assuan_context_t ctx, assuan_fd_t sockfd,
{
int res = bind (HANDLE2SOCKET(sockfd), addr, addrlen);
if (res < 0)
- errno = _assuan_sock_wsa2errno (WSAGetLastError ());
+ gpg_err_set_errno ( _assuan_sock_wsa2errno (WSAGetLastError ()));
return res;
}
#else
@@ -303,7 +303,7 @@ _assuan_sock_get_nonce (assuan_context_t ctx, struct sockaddr *addr,
if (sizeof nonce->nonce != 16)
{
- errno = EINVAL;
+ gpg_err_set_errno (EINVAL);
return -1;
}
nonce->length = 16;
@@ -336,7 +336,7 @@ _assuan_sock_check_nonce (assuan_context_t ctx, assuan_fd_t fd,
if (sizeof nonce->nonce != 16)
{
- errno = EINVAL;
+ gpg_err_set_errno (EINVAL);
return -1;
}
@@ -345,7 +345,7 @@ _assuan_sock_check_nonce (assuan_context_t ctx, assuan_fd_t fd,
if (nonce->length != 16)
{
- errno = EINVAL;
+ gpg_err_set_errno (EINVAL);
return -1;
}
@@ -362,7 +362,7 @@ _assuan_sock_check_nonce (assuan_context_t ctx, assuan_fd_t fd,
return -1;
else if (!n)
{
- errno = EIO;
+ gpg_err_set_errno (EIO);
return -1;
}
else
@@ -373,7 +373,7 @@ _assuan_sock_check_nonce (assuan_context_t ctx, assuan_fd_t fd,
}
if (memcmp (buffer, nonce->nonce, 16))
{
- errno = EACCES;
+ gpg_err_set_errno (EACCES);
return -1;
}
#else
diff --git a/src/assuan-uds.c b/src/assuan-uds.c
index ffa940a..2e0f821 100644
--- a/src/assuan-uds.c
+++ b/src/assuan-uds.c
@@ -136,7 +136,7 @@ uds_reader (assuan_context_t ctx, void *buf, size_t buflen)
#else /*HAVE_W32_SYSTEM*/
int res = recvfrom (HANDLE2SOCKET(ctx->inbound.fd), buf, buflen, 0, NULL, NULL);
if (res < 0)
- errno = _assuan_sock_wsa2errno (WSAGetLastError ());
+ gpg_err_set_errno (_assuan_sock_wsa2errno (WSAGetLastError ()));
return res;
#endif /*HAVE_W32_SYSTEM*/
}
@@ -168,7 +168,7 @@ uds_writer (assuan_context_t ctx, const void *buf, size_t buflen)
(struct sockaddr *)&ctx->serveraddr,
sizeof (struct sockaddr_in));
if (res < 0)
- errno = _assuan_sock_wsa2errno (WSAGetLastError ());
+ gpg_err_set_errno ( _assuan_sock_wsa2errno (WSAGetLastError ()));
return res;
#endif /*HAVE_W32_SYSTEM*/
}
diff --git a/src/debug.c b/src/debug.c
index 1b654b7..8c286e8 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -60,7 +60,7 @@ _assuan_debug (assuan_context_t ctx, unsigned int cat, const char *format, ...)
return;
ctx->log_cb (ctx, ctx->log_cb_data, cat, msg);
free (msg);
- errno = saved_errno;
+ gpg_err_set_errno (saved_errno);
}
diff --git a/src/system.c b/src/system.c
index 22019fb..9e9f5cf 100644
--- a/src/system.c
+++ b/src/system.c
@@ -57,7 +57,7 @@ assuan_fdopen (int fd)
GetCurrentProcess(), &ofd, 0,
TRUE, DUPLICATE_SAME_ACCESS))
{
- errno = EIO;
+ gpg_err_set_errno (EIO);
return ASSUAN_INVALID_FD;
}
return ofd;
@@ -92,7 +92,7 @@ _assuan_calloc (assuan_context_t ctx, size_t cnt, size_t elsize)
/* Check for overflow. */
if (elsize && nbytes / elsize != cnt)
{
- errno = ENOMEM;
+ gpg_err_set_errno (ENOMEM);
return NULL;
}
@@ -203,7 +203,7 @@ __assuan_pipe (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx)
{
TRACE1 (ctx, ASSUAN_LOG_SYSIO, "__assuan_pipe", ctx,
"CreatePipe failed: %s", _assuan_w32_strerror (ctx, -1));
- errno = EIO;
+ gpg_err_set_errno (EIO);
return -1;
}
@@ -215,7 +215,7 @@ __assuan_pipe (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx)
"DuplicateHandle failed: %s", _assuan_w32_strerror (ctx, -1));
CloseHandle (rh);
CloseHandle (wh);
- errno = EIO;
+ gpg_err_set_errno (EIO);
return -1;
}
if (inherit_idx == 0)
@@ -264,13 +264,13 @@ __assuan_close (assuan_context_t ctx, assuan_fd_t fd)
#ifdef HAVE_W32_SYSTEM
int rc = closesocket (HANDLE2SOCKET(fd));
if (rc)
- errno = _assuan_sock_wsa2errno (WSAGetLastError ());
+ gpg_err_set_errno ( _assuan_sock_wsa2errno (WSAGetLastError ()) );
if (rc && WSAGetLastError () == WSAENOTSOCK)
{
rc = CloseHandle (fd);
if (rc)
/* FIXME. */
- errno = EIO;
+ gpg_err_set_errno (EIO);
}
return rc;
#else
@@ -315,11 +315,11 @@ __assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size)
switch (GetLastError ())
{
case ERROR_BROKEN_PIPE:
- errno = EPIPE;
+ gpg_err_set_errno (EPIPE);
break;
default:
- errno = EIO;
+ gpg_err_set_errno (EIO);
}
res = -1;
}
@@ -329,15 +329,15 @@ __assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size)
break;
case WSAEWOULDBLOCK:
- errno = EAGAIN;
+ gpg_err_set_errno (EAGAIN);
break;
case ERROR_BROKEN_PIPE:
- errno = EPIPE;
+ gpg_err_set_errno (EPIPE);
break;
default:
- errno = EIO;
+ gpg_err_set_errno (EIO);
break;
}
}
@@ -385,11 +385,11 @@ __assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer,
{
case ERROR_BROKEN_PIPE:
case ERROR_NO_DATA:
- errno = EPIPE;
+ gpg_err_set_errno (EPIPE);
break;
default:
- errno = EIO;
+ gpg_err_set_errno (EIO);
break;
}
res = -1;
@@ -425,7 +425,7 @@ __assuan_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
int ret;
@@ -477,7 +477,7 @@ __assuan_sendmsg (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
int ret;
@@ -640,7 +640,7 @@ __assuan_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
TRACE1 (ctx, ASSUAN_LOG_SYSIO, "__assuan_spawn", ctx,
"can't open `nul': %s", _assuan_w32_strerror (ctx, -1));
_assuan_free (ctx, cmdline);
- errno = EIO;
+ gpg_err_set_errno (EIO);
return -1;
}
si.hStdError = nullfd;
@@ -675,7 +675,7 @@ __assuan_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
if (nullfd != INVALID_HANDLE_VALUE)
CloseHandle (nullfd);
- errno = EIO;
+ gpg_err_set_errno (EIO);
return -1;
}
@@ -818,7 +818,7 @@ __assuan_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
if (!(fdp && *fdp != -1))
close (i);
}
- errno = 0;
+ gpg_err_set_errno (0);
if (! name)
{
@@ -948,7 +948,7 @@ __assuan_socketpair (assuan_context_t ctx, int namespace, int style,
int protocol, assuan_fd_t filedes[2])
{
#if HAVE_W32_SYSTEM
- errno = ENOSYS;
+ gpg_err_set_errno (ENOSYS);
return -1;
#else
return socketpair (namespace, style, protocol, filedes);