From 9bf9c732f9d39d691e1f8841e7204c9c26321946 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 24 Feb 2018 10:43:13 -0500 Subject: [PATCH] remove obfuscated flags bit-twiddling logic in __stdio_read replace with simple conditional that doesn't rely on assumption that cnt is either 0 or -1. --- src/stdio/__stdio_read.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index f8fa6d3b..af50508c 100644 --- a/src/stdio/__stdio_read.c +++ b/src/stdio/__stdio_read.c @@ -11,7 +11,7 @@ size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) cnt = syscall(SYS_readv, f->fd, iov, 2); if (cnt <= 0) { - f->flags |= F_EOF ^ ((F_ERR^F_EOF) & cnt); + f->flags |= cnt ? F_ERR : F_EOF; return cnt; } if (cnt <= iov[0].iov_len) return cnt; -- 2.25.1