diff options
| author | NIIBE Yutaka <[email protected]> | 2026-02-26 01:53:32 +0100 |
|---|---|---|
| committer | NIIBE Yutaka <[email protected]> | 2026-02-26 01:53:32 +0100 |
| commit | c2c60d911b0913081e4a0c0903795f9d9f49fe7b (patch) | |
| tree | ec20cc31e4bdd43d639df30f7238a9726b13cf85 /src | |
| parent | doc: Update Known Problems section in README. (diff) | |
| download | libgpg-error-c2c60d911b0913081e4a0c0903795f9d9f49fe7b.tar.gz libgpg-error-c2c60d911b0913081e4a0c0903795f9d9f49fe7b.zip | |
w32:estream: Use INVALID_SOCKET to check invalid socket.
* src/estream.c (IS_INVALID_SOCKET): New.
(func_sock_read, func_sock_write, func_sock_ioctl, func_sock_destroy):
Use IS_INVALID_SOCKET.
--
It is possible for some architectures that the value of extended -1
and ~0 is different in C. Better to avoid the issue in advance.
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/estream.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/estream.c b/src/estream.c index 7e1d55c..4bf3bd3 100644 --- a/src/estream.c +++ b/src/estream.c @@ -1223,6 +1223,7 @@ static struct cookie_io_functions_s estream_functions_fd = /* * Implementation of SOCKET based I/O. */ +#define IS_INVALID_SOCKET(a) ((a) == INVALID_SOCKET) /* Cookie for SOCKET objects. */ typedef struct estream_cookie_sock @@ -1276,7 +1277,7 @@ func_sock_read (void *cookie, void *buffer, size_t size) if (!size) bytes_read = -1; /* We don't know whether anything is pending. */ - else if (IS_INVALID_FD (file_cookie->sock)) + else if (IS_INVALID_SOCKET (file_cookie->sock)) { _gpgrt_yield (); bytes_read = 0; @@ -1308,7 +1309,7 @@ func_sock_write (void *cookie, const void *buffer, size_t size) trace (("enter: cookie=%p buffer=%p size=%d", cookie, buffer, (int)size)); - if (IS_INVALID_FD (file_cookie->sock)) + if (IS_INVALID_SOCKET (file_cookie->sock)) { _gpgrt_yield (); bytes_written = size; /* Yeah: Success writing to the bit bucket. */ @@ -1358,7 +1359,7 @@ func_sock_ioctl (void *cookie, int cmd, void *ptr, size_t *len) if (cmd == COOKIE_IOCTL_NONBLOCK && !len) { sock_cookie->nonblock = !!ptr; - if (IS_INVALID_FD (sock_cookie->sock)) + if (IS_INVALID_SOCKET (sock_cookie->sock)) { _set_errno (EINVAL); ret = -1; @@ -1395,7 +1396,7 @@ func_sock_destroy (void *cookie) if (sock_cookie) { - if (IS_INVALID_FD (sock_cookie->sock)) + if (IS_INVALID_SOCKET (sock_cookie->sock)) err = 0; else err = sock_cookie->no_close? 0 : closesocket (sock_cookie->sock); |
