Skip to content

Commit 856efed

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 b1f14dd commit 856efed

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
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+
#if defined(__GNUC__) && !defined(__clang__)
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+
#if defined(__GNUC__) && !defined(__clang__)
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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,15 @@ 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+
355+
#if defined(__GNUC__) && !defined(__clang__)
356+
#pragma GCC diagnostic push
357+
#pragma GCC diagnostic ignored "-Wlogical-op"
358+
#endif
354359
if (errno == EWOULDBLOCK || errno == EAGAIN) {
360+
#if defined(__GNUC__) && !defined(__clang__)
361+
#pragma GCC diagnostic pop
362+
#endif
355363
return 0;
356364
}
357365
if (errno == EINTR) {
@@ -420,7 +428,15 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
420428
}
421429

422430
if (ret < 0) {
431+
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
432+
#if defined(__GNUC__) && !defined(__clang__)
433+
#pragma GCC diagnostic push
434+
#pragma GCC diagnostic ignored "-Wlogical-op"
435+
#endif
423436
if (errno == EWOULDBLOCK || errno == EAGAIN) {
437+
#if defined(__GNUC__) && !defined(__clang__)
438+
#pragma GCC diagnostic pop
439+
#endif
424440
/* Not an error. */
425441
ret = 0;
426442
} else if (errno == EINTR) {

main/streams/xp_socket.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ 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+
79+
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
80+
#if defined(__GNUC__) && !defined(__clang__)
81+
#pragma GCC diagnostic push
82+
#pragma GCC diagnostic ignored "-Wlogical-op"
83+
#endif
7884
if (err == EWOULDBLOCK || err == EAGAIN) {
85+
#if defined(__GNUC__) && !defined(__clang__)
86+
#pragma GCC diagnostic pop
87+
#endif
7988
if (sock->is_blocked) {
8089
int retval;
8190

@@ -166,7 +175,15 @@ static ssize_t php_sockop_read(php_stream *stream, char *buf, size_t count)
166175
err = php_socket_errno();
167176

168177
if (nr_bytes < 0) {
178+
/* See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
179+
#if defined(__GNUC__) && !defined(__clang__)
180+
#pragma GCC diagnostic push
181+
#pragma GCC diagnostic ignored "-Wlogical-op"
182+
#endif
169183
if (err == EAGAIN || err == EWOULDBLOCK) {
184+
#if defined(__GNUC__) && !defined(__clang__)
185+
#pragma GCC diagnostic pop
186+
#endif
170187
nr_bytes = 0;
171188
} else {
172189
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+
#if defined(__GNUC__) && !defined(__clang__)
171+
#pragma GCC diagnostic push
172+
#pragma GCC diagnostic ignored "-Wlogical-op"
173+
#endif
169174
if (in_buf == 0 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
175+
#if defined(__GNUC__) && !defined(__clang__)
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)