summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2016-11-18 10:05:12 -0500
committerKaleb KEITHLEY <kkeithle@redhat.com>2017-02-26 14:15:14 -0500
commit4638dfc1fee80f9338f2941f3cccb17bec63989a (patch)
tree7955fb0600daaa6b71bf099c4371d7548b2437bc
parentece5f66a3d05628bb1a74833ae695443e079f80d (diff)
events: use attribute(format(/printf)) to catch fmt string errors
and statedump too. Also "const char *" (versus just "char *") for the fmt param. Change-Id: Ic63734a673208a2cd49aebccce7659816e6179e3 BUG: 1399196 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: https://review.gluster.org/15881 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
-rw-r--r--libglusterfs/src/dict.c2
-rw-r--r--libglusterfs/src/events.c2
-rw-r--r--libglusterfs/src/events.h6
-rw-r--r--libglusterfs/src/latency.c2
-rw-r--r--libglusterfs/src/statedump.h8
-rw-r--r--xlators/debug/io-stats/src/io-stats.c4
-rw-r--r--xlators/performance/write-behind/src/write-behind.c2
7 files changed, 14 insertions, 12 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 96cb9e94bda..a0de0947b1a 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -2983,7 +2983,7 @@ dict_dump_to_statedump (dict_t *dict, char *dict_name, char *domain)
"Failed to log dictionary %s", dict_name);
return;
}
- gf_proc_dump_build_key (key, domain, dict_name);
+ gf_proc_dump_build_key (key, domain, "%s", dict_name);
gf_proc_dump_write (key, "%s", dump);
return;
diff --git a/libglusterfs/src/events.c b/libglusterfs/src/events.c
index 27c421a7c74..7c20c32ad6e 100644
--- a/libglusterfs/src/events.c
+++ b/libglusterfs/src/events.c
@@ -31,7 +31,7 @@
int
-_gf_event (eventtypes_t event, char *fmt, ...)
+_gf_event (eventtypes_t event, const char *fmt, ...)
{
int ret = 0;
int sock = -1;
diff --git a/libglusterfs/src/events.h b/libglusterfs/src/events.h
index e059bc9c4d1..19988b0e3d2 100644
--- a/libglusterfs/src/events.h
+++ b/libglusterfs/src/events.h
@@ -15,10 +15,12 @@
#ifdef USE_EVENTS
int
-_gf_event (eventtypes_t event, char *fmt, ...);
+_gf_event (eventtypes_t event, const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 2, 3)));
#else
+__attribute__ ((__format__ (__printf__, 2, 3)))
static inline int
-_gf_event (eventtypes_t event, char *fmt, ...)
+_gf_event (eventtypes_t event, const char *fmt, ...)
{
return 0;
}
diff --git a/libglusterfs/src/latency.c b/libglusterfs/src/latency.c
index 611615949fa..5025de6c8cf 100644
--- a/libglusterfs/src/latency.c
+++ b/libglusterfs/src/latency.c
@@ -164,7 +164,7 @@ gf_proc_dump_latency_info (xlator_t *xl)
gf_proc_dump_add_section (key_prefix);
for (i = 0; i < GF_FOP_MAXVALUE; i++) {
- gf_proc_dump_build_key (key, key_prefix,
+ gf_proc_dump_build_key (key, key_prefix, "%s",
(char *)gf_fop_list[i]);
gf_proc_dump_write (key, "%.03f,%"PRId64",%.03f",
diff --git a/libglusterfs/src/statedump.h b/libglusterfs/src/statedump.h
index 39a68bd69da..0a7a97e10d4 100644
--- a/libglusterfs/src/statedump.h
+++ b/libglusterfs/src/statedump.h
@@ -37,13 +37,13 @@ typedef struct gf_dump_options_ {
extern gf_dump_options_t dump_options;
-static inline
-void _gf_proc_dump_build_key (char *key, const char *prefix, char *fmt,...)
+__attribute__ ((__format__ (__printf__, 3, 4)))
+static inline void
+_gf_proc_dump_build_key (char *key, const char *prefix, const char *fmt, ...)
{
- char buf[GF_DUMP_MAX_BUF_LEN];
+ char buf[GF_DUMP_MAX_BUF_LEN] = { 0, };
va_list ap;
- memset(buf, 0, sizeof(buf));
va_start(ap, fmt);
vsnprintf(buf, GF_DUMP_MAX_BUF_LEN, fmt, ap);
va_end(ap);
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 7d33c06b680..d3b3136d982 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -3727,7 +3727,7 @@ io_priv (xlator_t *this)
max = conf->cumulative.latency[i].max;
avg = conf->cumulative.latency[i].avg;
- gf_proc_dump_build_key (key, key_prefix_cumulative,
+ gf_proc_dump_build_key (key, key_prefix_cumulative, "%s",
(char *)gf_fop_list[i]);
gf_proc_dump_write (key,"%"PRId64",%"PRId64",%.03f,%.03f,%.03f",
@@ -3739,7 +3739,7 @@ io_priv (xlator_t *this)
max = conf->incremental.latency[i].max;
avg = conf->incremental.latency[i].avg;
- gf_proc_dump_build_key (key, key_prefix_incremental,
+ gf_proc_dump_build_key (key, key_prefix_incremental, "%s",
(char *)gf_fop_list[i]);
gf_proc_dump_write (key,"%"PRId64",%"PRId64",%.03f,%.03f,%.03f",
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 738faea725e..d63c8b5c1d5 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -2784,7 +2784,7 @@ __wb_dump_requests (struct list_head *head, char *prefix)
wb_request_t *req = NULL;
list_for_each_entry (req, head, all) {
- gf_proc_dump_build_key (key_prefix, key,
+ gf_proc_dump_build_key (key_prefix, key, "%s",
(char *)gf_fop_list[req->fop]);
gf_proc_dump_add_section(key_prefix);