Skip to contentSkip to conversation

tracing: turn off -Wsuggest-attribute=format for sample

PATCH New Arnd Bergmann 1 participant 1 message Feb 3

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: turn off -Wsuggest-attribute=format for sample

From: Arnd Bergmann <[email protected]>

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.

---
 samples/trace_events/trace-events-sample.c | 2 ++
 1 file changed, 2 insertions(+)
samples/trace_events/trace-events-sample.c +2 -0
index ecc7db237f2e..9993fb5d5f98 100644
@@ -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[] = {
Signature · 1 line
2.39.5