From 84ebee8c20ce667a5ec5fddc0aa47f8b5bef39f8 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 18 Oct 2011 10:30:42 +0530 Subject: build: warning suppression (round n) with this patch, there are no more warnings with gcc (GCC) 4.6.1 20110908 Change-Id: Ice0d52d304b9846395f8a4a191c98eb53125f792 BUG: 2550 Reviewed-on: http://review.gluster.com/607 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/common-utils.c | 19 +++++++++++++++++++ libglusterfs/src/daemon.c | 9 ++++++++- libglusterfs/src/mem-pool.c | 3 +++ libglusterfs/src/options.c | 4 ++++ libglusterfs/src/statedump.c | 21 +++++++++++++-------- libglusterfs/src/statedump.h | 4 ++-- 6 files changed, 49 insertions(+), 11 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 2d4415f506d..e7d54d48b22 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -357,6 +357,9 @@ gf_print_trace (int32_t signum) /* Pending frames, (if any), list them in order */ ret = write (fd, "pending frames:\n", 16); + if (ret < 0) + goto out; + { glusterfs_ctx_t *ctx = glusterfs_ctx_get (); struct list_head *trav = ((call_pool_t *)ctx->pool)->all_frames.next; @@ -372,16 +375,25 @@ gf_print_trace (int32_t signum) gf_mgmt_list[tmp->root->op]); ret = write (fd, msg, strlen (msg)); + if (ret < 0) + goto out; + trav = trav->next; } ret = write (fd, "\n", 1); + if (ret < 0) + goto out; } sprintf (msg, "patchset: %s\n", GLUSTERFS_REPOSITORY_REVISION); ret = write (fd, msg, strlen (msg)); + if (ret < 0) + goto out; sprintf (msg, "signal received: %d\n", signum); ret = write (fd, msg, strlen (msg)); + if (ret < 0) + goto out; { /* Dump the timestamp of the crash too, so the previous logs @@ -390,7 +402,11 @@ gf_print_trace (int32_t signum) tm = localtime (&utime); strftime (timestr, 256, "%Y-%m-%d %H:%M:%S\n", tm); ret = write (fd, "time of crash: ", 15); + if (ret < 0) + goto out; ret = write (fd, timestr, strlen (timestr)); + if (ret < 0) + goto out; } gf_dump_config_flags (fd); @@ -404,9 +420,12 @@ gf_print_trace (int32_t signum) backtrace_symbols_fd (&array[1], size-1, fd); sprintf (msg, "---------\n"); ret = write (fd, msg, strlen (msg)); + if (ret < 0) + goto out; } #endif /* HAVE_BACKTRACE */ +out: /* Send a signal to terminate the process */ signal (signum, SIG_DFL); raise (signum); diff --git a/libglusterfs/src/daemon.c b/libglusterfs/src/daemon.c index 51b14810cc4..778196164b8 100644 --- a/libglusterfs/src/daemon.c +++ b/libglusterfs/src/daemon.c @@ -29,7 +29,6 @@ os_daemon_return (int nochdir, int noclose) int ret = -1; FILE *ptr = NULL; - ret = fork(); if (ret) return ret; @@ -46,8 +45,16 @@ os_daemon_return (int nochdir, int noclose) if (!noclose) { ptr = freopen (DEVNULLPATH, "r", stdin); + if (!ptr) + goto out; + ptr = freopen (DEVNULLPATH, "w", stdout); + if (!ptr) + goto out; + ptr = freopen (DEVNULLPATH, "w", stderr); + if (!ptr) + goto out; } ret = 0; diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index 95e91567e16..4cad56dd906 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -336,6 +336,9 @@ mem_pool_new_fn (unsigned long sizeof_type, return NULL; ret = gf_asprintf (&mem_pool->name, "%s:%s", THIS->name, name); + if (ret < 0) + return NULL; + if (!mem_pool->name) { GF_FREE (mem_pool); return NULL; diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c index 1e6413cc0a9..b8d3b6ae5a8 100644 --- a/libglusterfs/src/options.c +++ b/libglusterfs/src/options.c @@ -647,6 +647,10 @@ xl_opt_validate (dict_t *dict, char *key, data_t *value, void *data) return; ret = xlator_option_validate (xl, key, value->data, opt, &errstr); + if (ret) + gf_log (xl->name, GF_LOG_WARNING, "validate of %s returned %d", + key, ret); + if (errstr) /* possible small leak of previously set stub->errstr */ stub->errstr = errstr; diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index 52de73b50e3..c744c6c5ff8 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -88,13 +88,12 @@ gf_proc_dump_close (void) } -void +int gf_proc_dump_add_section (char *key, ...) { char buf[GF_DUMP_MAX_BUF_LEN]; va_list ap; - int ret; GF_ASSERT(key); @@ -106,18 +105,17 @@ gf_proc_dump_add_section (char *key, ...) va_end (ap); snprintf (buf + strlen(buf), GF_DUMP_MAX_BUF_LEN - strlen (buf), "]\n"); - ret = write (gf_dump_fd, buf, strlen (buf)); + return write (gf_dump_fd, buf, strlen (buf)); } -void +int gf_proc_dump_write (char *key, char *value,...) { char buf[GF_DUMP_MAX_BUF_LEN]; int offset = 0; va_list ap; - int ret; GF_ASSERT (key); @@ -133,7 +131,7 @@ gf_proc_dump_write (char *key, char *value,...) offset = strlen (buf); snprintf (buf + offset, GF_DUMP_MAX_BUF_LEN - offset, "\n"); - ret = write (gf_dump_fd, buf, strlen (buf)); + return write (gf_dump_fd, buf, strlen (buf)); } static void @@ -421,7 +419,12 @@ gf_proc_dump_parse_set_option (char *key, char *value) "matched key : %s\n", key); ret = write (gf_dump_fd, buf, strlen (buf)); - return -1; + /* warning suppression */ + if (ret >= 0) { + ret = -1; + goto out; + } + } opt_value = (strncasecmp (value, "yes", 3) ? @@ -429,7 +432,9 @@ gf_proc_dump_parse_set_option (char *key, char *value) GF_PROC_DUMP_SET_OPTION (*opt_key, opt_value); - return 0; + ret = 0; +out: + return ret; } static int diff --git a/libglusterfs/src/statedump.h b/libglusterfs/src/statedump.h index fb07f5927a2..1c56d6cfa8a 100644 --- a/libglusterfs/src/statedump.h +++ b/libglusterfs/src/statedump.h @@ -71,9 +71,9 @@ void gf_proc_dump_cleanup(void); void gf_proc_dump_info(int signum); -void gf_proc_dump_add_section(char *key,...); +int gf_proc_dump_add_section(char *key,...); -void gf_proc_dump_write(char *key, char *value,...); +int gf_proc_dump_write(char *key, char *value,...); void inode_table_dump(inode_table_t *itable, char *prefix); -- cgit