btrfs-progs: send-stream: use proper type for read return value

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2016-11-15 14:44:46 +01:00
parent 2513dfed8f
commit d13168cebf
1 changed files with 6 additions and 4 deletions

View File

@ -43,18 +43,20 @@ static int read_buf(struct btrfs_send_stream *sctx, char *buf, size_t len)
size_t pos = 0; size_t pos = 0;
while (pos < len) { while (pos < len) {
ret = read(sctx->fd, buf + pos, len - pos); ssize_t rbytes;
if (ret < 0) {
rbytes = read(sctx->fd, buf + pos, len - pos);
if (rbytes < 0) {
ret = -errno; ret = -errno;
error("read from stream failed: %s", error("read from stream failed: %s",
strerror(-ret)); strerror(-ret));
goto out; goto out;
} }
if (ret == 0) { if (rbytes == 0) {
ret = 1; ret = 1;
goto out; goto out;
} }
pos += ret; pos += rbytes;
} }
ret = 0; ret = 0;