static void safe_read(int fd, void *buffer, unsigned size)
{
- int n = 0;
+ size_t n = 0;
while (n < size) {
- int ret = xread(fd, (char *) buffer + n, size - n);
+ ssize_t ret = xread(fd, (char *) buffer + n, size - n);
if (ret < 0)
die("read error (%s)", strerror(errno));
if (!ret)
- die("unexpected EOF");
+ die("The remote end hung up unexpectedly");
n += ret;
}
}