check return for write() in one of the test tools

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
libnfs-4.0.0-vitalif
Ronnie Sahlberg 2019-02-05 13:18:11 +10:00
parent 38b62bcf87
commit 9e031df11d
1 changed files with 12 additions and 2 deletions

View File

@ -43,7 +43,7 @@ int main(int argc, char *argv[])
struct nfs_context *nfs = NULL;
struct nfs_url *url = NULL;
int ret = 0;
int flags = 0, count;
int flags = 0, count, res, pos;
struct nfsfh *fh;
char buf[1024];
@ -111,7 +111,17 @@ int main(int argc, char *argv[])
goto finished;
}
write(1, buf, count);
pos = 0;
while (count) {
res = write(1, &buf[pos], count);
if (res < 0) {
fprintf(stderr, "write() failed\n");
ret = 1;
goto finished;
}
count -= res;
pos += res;
}
if (nfs_close(nfs, fh)) {
fprintf(stderr, "Failed to close(): %s\n",