Skip to content

Commit fcd587d

Browse files
committed
Suppress bogus [-Wlogical-op] for (errno == EWOULDBLOCK || errno == EAGAIN)
1 parent 0568d10 commit fcd587d

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

ext/sockets/sockets.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,11 +1045,15 @@ PHP_FUNCTION(socket_read)
10451045
if (retval == -1) {
10461046
/* if the socket is in non-blocking mode and there's no data to read,
10471047
don't output any error, as this is a normal situation, and not an error */
1048+
1049+
#pragma GCC diagnostic push
1050+
#pragma GCC diagnostic ignored "-Wlogical-op"
10481051
if (errno == EAGAIN
10491052
#ifdef EWOULDBLOCK
10501053
|| errno == EWOULDBLOCK
10511054
#endif
10521055
) {
1056+
#pragma GCC diagnostic pop
10531057
php_sock->error = errno;
10541058
SOCKETS_G(last_error) = errno;
10551059
} else {

main/streams/plain_wrapper.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t coun
351351
ssize_t bytes_written = write(data->fd, buf, count);
352352
#endif
353353
if (bytes_written < 0) {
354+
#pragma GCC diagnostic push
355+
#pragma GCC diagnostic ignored "-Wlogical-op"
354356
if (errno == EWOULDBLOCK || errno == EAGAIN) {
357+
#pragma GCC diagnostic pop
355358
return 0;
356359
}
357360
if (errno == EINTR) {
@@ -420,7 +423,10 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
420423
}
421424

422425
if (ret < 0) {
426+
#pragma GCC diagnostic push
427+
#pragma GCC diagnostic ignored "-Wlogical-op"
423428
if (errno == EWOULDBLOCK || errno == EAGAIN) {
429+
#pragma GCC diagnostic pop
424430
/* Not an error. */
425431
ret = 0;
426432
} else if (errno == EINTR) {

main/streams/xp_socket.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ static ssize_t php_sockop_write(php_stream *stream, const char *buf, size_t coun
7575
if (didwrite <= 0) {
7676
char *estr;
7777
int err = php_socket_errno();
78+
#pragma GCC diagnostic push
79+
#pragma GCC diagnostic ignored "-Wlogical-op"
7880
if (err == EWOULDBLOCK || err == EAGAIN) {
81+
#pragma GCC diagnostic pop
7982
if (sock->is_blocked) {
8083
int retval;
8184

@@ -166,7 +169,10 @@ static ssize_t php_sockop_read(php_stream *stream, char *buf, size_t count)
166169
err = php_socket_errno();
167170

168171
if (nr_bytes < 0) {
169-
if (err == EAGAIN || err == EWOULDBLOCK) {
172+
#pragma GCC diagnostic push
173+
#pragma GCC diagnostic ignored "-Wlogical-op"
174+
if (err == EWOULDBLOCK || err == EAGAIN) {
175+
#pragma GCC diagnostic pop
170176
nr_bytes = 0;
171177
} else {
172178
stream->eof = 1;

sapi/fpm/fpm/fpm_stdio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
166166
stdio_read:
167167
in_buf = read(fd, buf, max_buf_size - 1);
168168
if (in_buf <= 0) { /* no data */
169+
#pragma GCC diagnostic push
170+
#pragma GCC diagnostic ignored "-Wlogical-op"
169171
if (in_buf == 0 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
172+
#pragma GCC diagnostic pop
170173
/* pipe is closed or error */
171174
read_fail = (in_buf < 0) ? in_buf : 1;
172175
}

0 commit comments

Comments
 (0)