summaryrefslogtreecommitdiff
path: root/ext/sockets
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-09-23 23:46:58 +0100
committerGeorge Peter Banyard <girgias@php.net>2020-10-10 14:45:20 +0100
commit150ebfdf77320b24b0358f8a903e90d7940ad4a4 (patch)
tree06e83f7b7f4fed49bdc08033d093aa94dad9ac8f /ext/sockets
parentf211f1586f1e93acee49df852b999b9402d32f5d (diff)
downloadphp-git-150ebfdf77320b24b0358f8a903e90d7940ad4a4.tar.gz
Suppress bogus [-Wlogical-op] warning from GCC
See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 which emits the warning for (errno == EWOULDBLOCK || errno == EAGAIN) which is the correct way of handling errors as the value of EWOULDBLOCK and EAGAIN is implementation defined. Therefore introduce a new macro function PHP_IS_TRANSIENT_ERROR() which handles the case when EWOULDBLOCK and EAGAIN are identical. Thanks to @twose for the idea.
Diffstat (limited to 'ext/sockets')
-rw-r--r--ext/sockets/sockets.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 0b21c4f684..c50d8d5d71 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -1045,11 +1045,7 @@ PHP_FUNCTION(socket_read)
if (retval == -1) {
/* if the socket is in non-blocking mode and there's no data to read,
don't output any error, as this is a normal situation, and not an error */
- if (errno == EAGAIN
-#ifdef EWOULDBLOCK
- || errno == EWOULDBLOCK
-#endif
- ) {
+ if (PHP_IS_TRANSIENT_ERROR(errno)) {
php_sock->error = errno;
SOCKETS_G(last_error) = errno;
} else {