Browse Source

perf probe: Check e_snprintf() format string

Check e_snprintf() format string by gcc, and fix a bug of
e_snprintf() caller.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20091207170053.19230.7690.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Masami Hiramatsu 15 years ago
parent
commit
849884508e
1 changed files with 4 additions and 1 deletions
  1. 4 1
      tools/perf/util/probe-event.c

+ 4 - 1
tools/perf/util/probe-event.c

@@ -47,6 +47,9 @@
 #define semantic_error(msg ...) die("Semantic error :" msg)
 #define semantic_error(msg ...) die("Semantic error :" msg)
 
 
 /* If there is no space to write, returns -E2BIG. */
 /* If there is no space to write, returns -E2BIG. */
+static int e_snprintf(char *str, size_t size, const char *format, ...)
+	__attribute__((format(printf, 3, 4)));
+
 static int e_snprintf(char *str, size_t size, const char *format, ...)
 static int e_snprintf(char *str, size_t size, const char *format, ...)
 {
 {
 	int ret;
 	int ret;
@@ -258,7 +261,7 @@ int synthesize_perf_probe_event(struct probe_point *pp)
 		ret = e_snprintf(buf, MAX_CMDLEN, "%s%s%s%s", pp->function,
 		ret = e_snprintf(buf, MAX_CMDLEN, "%s%s%s%s", pp->function,
 				 offs, pp->retprobe ? "%return" : "", line);
 				 offs, pp->retprobe ? "%return" : "", line);
 	else
 	else
-		ret = e_snprintf(buf, MAX_CMDLEN, "%s%s%s%s", pp->file, line);
+		ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", pp->file, line);
 	if (ret <= 0)
 	if (ret <= 0)
 		goto error;
 		goto error;
 	len = ret;
 	len = ret;