From f265d04ab8214f4789a7ff971acba3d97b84a0e0 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 28 Dec 2011 13:01:12 -0600 Subject: Bugfix (spotted by Nathan McSween): xread can't detect <0 if the return type is stored in an unsigned variable. --- lib/lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/lib.c b/lib/lib.c index 8e557a8a..82e32aee 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -246,10 +246,10 @@ ssize_t writeall(int fd, void *buf, size_t len) // Die if there's an error other than EOF. size_t xread(int fd, void *buf, size_t len) { - len = read(fd, buf, len); - if (len < 0) perror_exit("xread"); + ssize_t ret = read(fd, buf, len); + if (ret < 0) perror_exit("xread"); - return len; + return ret; } void xreadall(int fd, void *buf, size_t len) -- cgit v1.2.3