From b688d911ea128809ad2878060aa83eb1908330a0 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 17 Aug 2012 16:48:02 +1000 Subject: [PATCH] 0 is a valid return value for read so only break out if read returns -1. --- fpgautils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpgautils.c b/fpgautils.c index a62b4913..57bd7d5f 100644 --- a/fpgautils.c +++ b/fpgautils.c @@ -252,7 +252,7 @@ _serial_read(int fd, char *buf, size_t bufsiz, char *eol) ssize_t len, tlen = 0; while (bufsiz) { len = read(fd, buf, eol ? 1 : bufsiz); - if (len < 1) + if (unlikely(len == -1)) break; tlen += len; if (eol && *eol == buf[0])