diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c --- a/usr.bin/wc/wc.c +++ b/usr.bin/wc/wc.c @@ -214,9 +214,10 @@ static int cnt(const char *file) { - char buf[MAXBSIZE], *p; + static char buf[MAXBSIZE]; struct stat sb; mbstate_t mbs; + const char *p; uintmax_t linect, wordct, charct, llct, tmpll; ssize_t len; size_t clen; @@ -259,7 +260,7 @@ * lines than to get words, since the word count requires locale * handling. */ - while ((len = read(fd, buf, sizeof(buf)))) { + while ((len = read(fd, buf, sizeof(buf))) != 0) { if (len < 0) { xo_warn("%s: read", file); (void)close(fd);