All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: <linux-trace-devel@vger.kernel.org>
Cc: Nicolas Sterchele <nicolas@sterchelen.net>,
	"Steven Rostedt (VMware)" <rostedt@goodmis.org>
Subject: [PATCH 1/2] trace-cmd: Add printf format attribute to die() and warning()
Date: Thu, 22 Apr 2021 17:07:29 -0400	[thread overview]
Message-ID: <20210422210730.857958-2-rostedt@goodmis.org> (raw)
In-Reply-To: <20210422210730.857958-1-rostedt@goodmis.org>

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 --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);
 
-- 
2.29.2


  reply	other threads:[~2021-04-22 21:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 21:07 [PATCH 0/2] trace-cmd: Add gcc printf format specifier Steven Rostedt
2021-04-22 21:07 ` Steven Rostedt [this message]
2021-04-22 21:07 ` [PATCH 2/2] trace-cmd: Fix up the die() formats Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210422210730.857958-2-rostedt@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=nicolas@sterchelen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.