diff --git a/lib/stdio/lib_fgets.c b/lib/stdio/lib_fgets.c index 3f72f00005a..ce2aa9476d2 100644 --- a/lib/stdio/lib_fgets.c +++ b/lib/stdio/lib_fgets.c @@ -97,7 +97,10 @@ static const char g_erasetoeol[] = "\033[K"; static inline int _lib_rawgetc(int fd) { char buffer; - if (read(fd, &buffer, 1) < 1) + ssize_t nread; + + nread = read(fd, &buffer, 1); + if (nread < 1) { /* Return EOF if the end of file (0) or error (-1) occurs */