Re: [kbuild-all] Re: include/trace/trace_events.h:261:16: error: function 'trace_event_get_offsets_iwlwifi_dbg' might be a candidate for 'gnu_printf' format attribute

From: Steven Rostedt
Date: Mon Oct 24 2022 - 21:27:03 EST


On Tue, 25 Oct 2022 08:49:41 +0800
"Chen, Rong A" <rong.a.chen@xxxxxxxxx> wrote:

> > For any build that fails on warnings, that specific warning needs to be
> > silenced.
> >
> > I mean, "-Werror=suggest-attribute=format", really?
>
> yes, it's compiled with -Werror if using 'W=1' option:
>
> >>>>>> include/trace/trace_events.h:261:16: error: function
> 'trace_event_get_offsets_iwlwifi_dbg' might be a candidate for
> 'gnu_printf' format attribute [-Werror=suggest-attribute=format]

Is there a way we can silent this particular error when W=1?

Ooh! Doing a search of this I found:

include/trace/events/qla.h:#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"

Perhaps I should just make that part of trace_events.h ?

-- Steve

(untested)

diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index c2f9cabf154d..63db95559647 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -18,6 +18,11 @@
* in the structure.
*/

+#pragma GCC diagnostic push
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
+#endif
+
#include <linux/trace_events.h>

#ifndef TRACE_SYSTEM_VAR
@@ -467,3 +472,5 @@ static struct trace_event_call __used \
__section("_ftrace_events") *__event_##call = &event_##call

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+#pragma GCC diagnostic pop