Skip to content

Commit 9b388e7

Browse files
committed
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.
1 parent 1be8f7c commit 9b388e7

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

ext/sockets/sockets.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,11 +1045,20 @@ 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+
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
1050+
#ifdef __GNUC__
1051+
#pragma GCC diagnostic push
1052+
#pragma GCC diagnostic ignored "-Wlogical-op"
1053+
#endif
10481054
if (errno == EAGAIN
10491055
#ifdef EWOULDBLOCK
10501056
|| errno == EWOULDBLOCK
10511057
#endif
10521058
) {
1059+
#ifdef __GNUC__
1060+
#pragma GCC diagnostic pop
1061+
#endif
10531062
php_sock->error = errno;
10541063
SOCKETS_G(last_error) = errno;
10551064
} else {

main/streams/plain_wrapper.c

Lines changed: 11 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,15 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
420423
}
421424

422425
if (ret < 0) {
426+
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
427+
#ifdef __GNUC__
428+
#pragma GCC diagnostic push
429+
#pragma GCC diagnostic ignored "-Wlogical-op"
430+
#endif
423431
if (errno == EWOULDBLOCK || errno == EAGAIN) {
432+
#ifdef __GNUC__
433+
#pragma GCC diagnostic pop
434+
#endif
424435
/* Not an error. */
425436
ret = 0;
426437
} else if (errno == EINTR) {

main/streams/xp_socket.c

Lines changed: 12 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,15 @@ 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+
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
173+
#ifdef __GNUC__
174+
#pragma GCC diagnostic push
175+
#pragma GCC diagnostic ignored "-Wlogical-op"
176+
#endif
177+
if (err == EWOULDBLOCK || err == EAGAIN) {
178+
#ifdef __GNUC__
179+
#pragma GCC diagnostic pop
180+
#endif
170181
nr_bytes = 0;
171182
} else {
172183
stream->eof = 1;

sapi/fpm/fpm/fpm_stdio.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,15 @@ 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+
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
170+
#ifdef __GNUC__
171+
#pragma GCC diagnostic push
172+
#pragma GCC diagnostic ignored "-Wlogical-op"
173+
#endif
169174
if (in_buf == 0 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
175+
#ifdef __GNUC__
176+
#pragma GCC diagnostic pop
177+
#endif
170178
/* pipe is closed or error */
171179
read_fail = (in_buf < 0) ? in_buf : 1;
172180
}

0 commit comments

Comments
 (0)