changeset 399:7a5b70965e0e

Bugfix (spotted by Nathan McSween): xread can't detect <0 if the return type is stored in an unsigned variable.
author Rob Landley <rob@landley.net>
date Wed, 28 Dec 2011 13:01:12 -0600
parents a4dcbad4f92a
children a5ceeeae7f43
files lib/lib.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib/lib.c	Mon Dec 12 23:49:55 2011 -0600
+++ b/lib/lib.c	Wed Dec 28 13:01:12 2011 -0600
@@ -246,10 +246,10 @@
 // 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)