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.
This commit is contained in:
Christoph M. Becker 2022-04-26 14:41:47 +02:00
parent b5db594fd2
commit 3c28be8255
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6

View File

@ -864,7 +864,10 @@ static ssize_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t c
while (data->fd >= 0) {
struct stat stat[3];
memset(stat, 0, sizeof(stat));
if (((fstat(fileno(stderr), &stat[2]) < 0) & (fstat(fileno(stdout), &stat[0]) < 0)) | (fstat(data->fd, &stat[1]) < 0)) {
int stat_stderr = fstat(fileno(stderr), &stat[2]);
int stat_stdout = fstat(fileno(stdout), &stat[0]);
int stat_datafd = fstat(data->fd, &stat[1]);
if ((stat_stderr < 0 && stat_stdout < 0) || stat_datafd < 0) {
break;
}