Bugfix (spotted by Nathan McSween): xread can't detect <0 if the return type is store...
authorRob Landley <rob@landley.net>
Wed, 28 Dec 2011 19:01:12 +0000 (13:01 -0600)
committerRob Landley <rob@landley.net>
Wed, 28 Dec 2011 19:01:12 +0000 (13:01 -0600)
lib/lib.c

index 8e557a8..82e32ae 100644 (file)
--- 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)