diff options
author | Sumit Bose <sbose@redhat.com> | 2009-05-20 12:08:13 +0200 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2009-05-21 11:22:21 +1000 |
commit | 2fcedf6dac9dd275adbb0017e53547614df29d93 (patch) | |
tree | 94a290c1514cd2446139e31a6403466018355f73 /ctdb/utils | |
parent | 11988fc77a06c50c251acec1dc8cc2c275f68310 (diff) | |
download | samba-2fcedf6dac9dd275adbb0017e53547614df29d93.tar.gz |
add missing checks on so far ignored return values
Most of these were found during a review by Jim Meyering <meyering@redhat.com>
(This used to be ctdb commit 3aee5ee1deb4a19be3bd3a4ce3abbe09de763344)
Diffstat (limited to 'ctdb/utils')
-rw-r--r-- | ctdb/utils/ping_pong/ping_pong.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ctdb/utils/ping_pong/ping_pong.c b/ctdb/utils/ping_pong/ping_pong.c index 90692e59ecc..27ff0577ac1 100644 --- a/ctdb/utils/ping_pong/ping_pong.c +++ b/ctdb/utils/ping_pong/ping_pong.c @@ -92,16 +92,29 @@ static void ping_pong(int fd, int num_locks) unsigned char *val; unsigned char incr=0, last_incr=0; unsigned char *p = NULL; + int ret; - ftruncate(fd, num_locks+1); + ret = ftruncate(fd, num_locks+1); + if (ret == -1) { + printf("ftruncate failed: %s\n", strerror(errno)); + return; + } if (use_mmap) { p = mmap(NULL, num_locks+1, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + if (p == MAP_FAILED) { + printf("mmap failed: %s\n", strerror(errno)); + return; + } } val = (unsigned char *)calloc(num_locks+1, sizeof(unsigned char)); + if (val == NULL) { + printf("calloc failed\n"); + return; + } - start_timer(); + start_timer(); lock_range(fd, 0, 1); i = 0; |