Skip to content

Commit 3c28be8

Browse files
committed
Close GH-8306: don't use of bitwise '|' with boolean operands
The code used bitwise operators to avoid the short-circuiting behavior of the logical operators. We refactor for clarity, and to keep compilers and static analyzers happy. Closes GH-8442.
1 parent b5db594 commit 3c28be8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sapi/phpdbg/phpdbg.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,10 @@ static ssize_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t c
864864
while (data->fd >= 0) {
865865
struct stat stat[3];
866866
memset(stat, 0, sizeof(stat));
867-
if (((fstat(fileno(stderr), &stat[2]) < 0) & (fstat(fileno(stdout), &stat[0]) < 0)) | (fstat(data->fd, &stat[1]) < 0)) {
867+
int stat_stderr = fstat(fileno(stderr), &stat[2]);
868+
int stat_stdout = fstat(fileno(stdout), &stat[0]);
869+
int stat_datafd = fstat(data->fd, &stat[1]);
870+
if ((stat_stderr < 0 && stat_stdout < 0) || stat_datafd < 0) {
868871
break;
869872
}
870873

0 commit comments

Comments
 (0)