From 2fcedf6dac9dd275adbb0017e53547614df29d93 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Wed, 20 May 2009 12:08:13 +0200 Subject: add missing checks on so far ignored return values Most of these were found during a review by Jim Meyering (This used to be ctdb commit 3aee5ee1deb4a19be3bd3a4ce3abbe09de763344) --- ctdb/utils/ping_pong/ping_pong.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'ctdb/utils') 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; -- cgit