diff mbox series

[1/2] trace-cmd: Add printf format attribute to die() and warning()

Message ID 20210422210730.857958-2-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 376642ff5a9932f7aa9d69cfc8f0e0a22bf136c3
Headers show
Series trace-cmd: Add gcc printf format specifier | expand

Commit Message

Steven Rostedt April 22, 2021, 9:07 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Add the gcc printf format attribute to die(), __die() and warning() such
that any mistake in the formats of the output will be caught by the
compiler.

Link: https://lore.kernel.org/linux-trace-devel/20210422165148.6d0ea90e@gandalf.local.home/

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracecmd/include/trace-local.h | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h
index 4235ae21..eadf103e 100644
--- a/tracecmd/include/trace-local.h
+++ b/tracecmd/include/trace-local.h
@@ -27,6 +27,9 @@  typedef unsigned long long u64;
 
 struct buffer_instance;
 
+#define __printf(a, b) __attribute__((format(printf,a,b)))
+
+__printf(1,2)
 void warning(const char *fmt, ...);
 
 /* for local shared information with trace-cmd executable */
@@ -331,8 +334,10 @@  int trace_open_vsock(unsigned int cid, unsigned int port);
 char *trace_get_guest_file(const char *file, const char *guest);
 
 /* No longer in event-utils.h */
+__printf(1,2)
 void __noreturn die(const char *fmt, ...); /* Can be overriden */
 void *malloc_or_die(unsigned int size); /* Can be overridden */
+__printf(1,2)
 void __noreturn __die(const char *fmt, ...);
 void __noreturn _vdie(const char *fmt, va_list ap);