[PATCH] tracing: turn off -Wsuggest-attribute=format for sample

Arnd Bergmann posted 1 patch 3 days, 22 hours ago
samples/trace_events/trace-events-sample.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] tracing: turn off -Wsuggest-attribute=format for sample
Posted by Arnd Bergmann 3 days, 22 hours ago
From: Arnd Bergmann <arnd@arndb.de>

The foo_bar tracing sample produces a few harmless warnings when
-Wsuggest-attribute=format is enabled, which can lead to failed
build in combination with -Werror:

In file included from include/trace/define_trace.h:132,
                 from samples/trace_events/trace-events-sample.h:640,
                 from samples/trace_events/trace-events-sample.c:12:
samples/trace_events/./trace-events-sample.h: In function 'trace_event_get_offsets_foo_bar':
include/trace/stages/stage5_get_offsets.h:33:31: error: function 'trace_event_get_offsets_foo_bar' might be a candidate for 'gnu_printf' format attribute [-Werror=suggest-attribute=format]
   33 |         { (void)sizeof(struct _test_no_array_##item *); }
      |                               ^~~~~~~~~~~~~~~

This seems to be a false positive and I can't see an obvious way to
annotate it, so instead just shut up that warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 samples/trace_events/trace-events-sample.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c
index ecc7db237f2e..9993fb5d5f98 100644
--- a/samples/trace_events/trace-events-sample.c
+++ b/samples/trace_events/trace-events-sample.c
@@ -9,6 +9,8 @@
  * creates the handles for the trace points.
  */
 #define CREATE_TRACE_POINTS
+__diag_ignore(GCC, all, "-Wsuggest-attribute=format",
+             "trace_event_get_offsets_foo_bar can't easily be annotated as __printf");
 #include "trace-events-sample.h"
 
 static const char *random_strings[] = {
-- 
2.39.5