diff mbox series

[04/13] tracing/brcm: Use the new __vstring() helper

Message ID 20220705224749.622796175@goodmis.org (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series None | expand

Commit Message

Steven Rostedt July 5, 2022, 10:44 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Instead of open coding a __dynamic_array() with a fixed length (which
defeats the purpose of the dynamic array in the first place). Use the new
__vstring() helper that will use a va_list and only write enough of the
string into the ring buffer that is needed.

Cc: Arend van Spriel <aspriel@gmail.com>
Cc: Franky Lin <franky.lin@broadcom.com>
Cc: Hante Meuleman <hante.meuleman@broadcom.com>
Cc: Kalle Valo <kvalo@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-wireless@vger.kernel.org
Cc: brcm80211-dev-list.pdl@broadcom.com
Cc: SHA-cyfmac-dev-list@infineon.com
Cc: netdev@vger.kernel.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 .../broadcom/brcm80211/brcmfmac/tracepoint.h         | 12 ++++--------
 .../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h    | 12 ++++--------
 2 files changed, 8 insertions(+), 16 deletions(-)

Comments

kernel test robot July 6, 2022, 2:35 a.m. UTC | #1
Hi Steven,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on rostedt-trace/for-next]
[also build test WARNING on wireless-next/main wireless/main linus/master v5.19-rc5 next-20220705]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Steven-Rostedt/tracing-events-Add-__vstring-and-__assign_vstr-helpers/20220706-065125
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next
config: i386-allyesconfig
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/3c932e272fbef5f880bf07599554747106044b06
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Steven-Rostedt/tracing-events-Add-__vstring-and-__assign_vstr-helpers/20220706-065125
        git checkout 3c932e272fbef5f880bf07599554747106044b06
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/net/wireless/broadcom/brcm80211/brcmfmac/ drivers/net/wireless/broadcom/brcm80211/brcmsmac/ drivers/net/wireless/intel/iwlwifi/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:102,
                    from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
                    from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_get_offsets_brcmf_err':
>> include/trace/trace_events.h:261:16: warning: function 'trace_event_get_offsets_brcmf_err' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
     261 |         struct trace_event_raw_##call __maybe_unused *entry;            \
         |                ^~~~~~~~~~~~~~~~
   include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: note: in expansion of macro 'TRACE_EVENT'
      31 | TRACE_EVENT(brcmf_err,
         | ^~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_get_offsets_brcmf_dbg':
>> include/trace/trace_events.h:261:16: warning: function 'trace_event_get_offsets_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
     261 |         struct trace_event_raw_##call __maybe_unused *entry;            \
         |                ^~~~~~~~~~~~~~~~
   include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: note: in expansion of macro 'TRACE_EVENT'
      45 | TRACE_EVENT(brcmf_dbg,
         | ^~~~~~~~~~~
   In file included from include/trace/define_trace.h:102,
                    from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
                    from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_raw_event_brcmf_err':
   include/trace/trace_events.h:386:16: warning: function 'trace_event_raw_event_brcmf_err' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
     386 |         struct trace_event_raw_##call *entry;                           \
         |                ^~~~~~~~~~~~~~~~
   include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: note: in expansion of macro 'TRACE_EVENT'
      31 | TRACE_EVENT(brcmf_err,
         | ^~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_raw_event_brcmf_dbg':
   include/trace/trace_events.h:386:16: warning: function 'trace_event_raw_event_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
     386 |         struct trace_event_raw_##call *entry;                           \
         |                ^~~~~~~~~~~~~~~~
   include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: note: in expansion of macro 'TRACE_EVENT'
      45 | TRACE_EVENT(brcmf_dbg,
         | ^~~~~~~~~~~
   In file included from include/trace/define_trace.h:103,
                    from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
                    from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'perf_trace_brcmf_err':
   include/trace/perf.h:64:16: warning: function 'perf_trace_brcmf_err' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
      64 |         struct hlist_head *head;                                        \
         |                ^~~~~~~~~~
   include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: note: in expansion of macro 'TRACE_EVENT'
      31 | TRACE_EVENT(brcmf_err,
         | ^~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'perf_trace_brcmf_dbg':
   include/trace/perf.h:64:16: warning: function 'perf_trace_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
      64 |         struct hlist_head *head;                                        \
         |                ^~~~~~~~~~
   include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: note: in expansion of macro 'TRACE_EVENT'
      45 | TRACE_EVENT(brcmf_dbg,
         | ^~~~~~~~~~~
--
   In file included from include/trace/define_trace.h:102,
                    from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82,
                    from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38,
                    from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22:
   drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: In function 'trace_event_get_offsets_brcms_dbg':
>> include/trace/trace_events.h:261:16: warning: function 'trace_event_get_offsets_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
     261 |         struct trace_event_raw_##call __maybe_unused *entry;            \
         |                ^~~~~~~~~~~~~~~~
   include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: note: in expansion of macro 'TRACE_EVENT'
      59 | TRACE_EVENT(brcms_dbg,
         | ^~~~~~~~~~~
   In file included from include/trace/define_trace.h:102,
                    from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82,
                    from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38,
                    from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22:
   drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: In function 'trace_event_raw_event_brcms_dbg':
   include/trace/trace_events.h:386:16: warning: function 'trace_event_raw_event_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
     386 |         struct trace_event_raw_##call *entry;                           \
         |                ^~~~~~~~~~~~~~~~
   include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: note: in expansion of macro 'TRACE_EVENT'
      59 | TRACE_EVENT(brcms_dbg,
         | ^~~~~~~~~~~
   In file included from include/trace/define_trace.h:103,
                    from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82,
                    from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38,
                    from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22:
   drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: In function 'perf_trace_brcms_dbg':
   include/trace/perf.h:64:16: warning: function 'perf_trace_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
      64 |         struct hlist_head *head;                                        \
         |                ^~~~~~~~~~
   include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: note: in expansion of macro 'TRACE_EVENT'
      59 | TRACE_EVENT(brcms_dbg,
         | ^~~~~~~~~~~


vim +261 include/trace/trace_events.h

55de2c0b5610cb include/trace/trace_events.h Masami Hiramatsu         2021-11-22  253  
091ad3658e3c76 include/trace/ftrace.h       Ingo Molnar              2009-11-26  254  #undef DECLARE_EVENT_CLASS
091ad3658e3c76 include/trace/ftrace.h       Ingo Molnar              2009-11-26  255  #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
d0ee8f4a1f5f3d include/trace/trace_events.h Steven Rostedt (Red Hat  2015-05-13  256) static inline notrace int trace_event_get_offsets_##call(		\
62323a148fbeb0 include/trace/trace_events.h Steven Rostedt (Red Hat  2015-05-13  257) 	struct trace_event_data_offsets_##call *__data_offsets, proto)	\
7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  258  {									\
7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  259  	int __data_size = 0;						\
114e7b52dee69c include/trace/ftrace.h       Filipe Brandenburger     2014-02-28  260  	int __maybe_unused __item_length;				\
a7237765730a10 include/trace/trace_events.h Steven Rostedt (Red Hat  2015-05-13 @261) 	struct trace_event_raw_##call __maybe_unused *entry;		\
7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  262  									\
7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  263  	tstruct;							\
7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  264  									\
7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  265  	return __data_size;						\
7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  266  }
7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  267
Steven Rostedt July 6, 2022, 2:50 a.m. UTC | #2
On Wed, 6 Jul 2022 10:35:50 +0800
kernel test robot <lkp@intel.com> wrote:

> Hi Steven,
> 
> Thank you for the patch! Perhaps something to improve:
> 
> [auto build test WARNING on rostedt-trace/for-next]
> [also build test WARNING on wireless-next/main wireless/main linus/master v5.19-rc5 next-20220705]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
> 


> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):

OK, let's look at all the warnings.

> 
>    In file included from include/trace/define_trace.h:102,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_get_offsets_brcmf_err':
> >> include/trace/trace_events.h:261:16: warning: function 'trace_event_get_offsets_brcmf_err' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]  

 1. "might be a candidate for 'gnu_printf' format attribute"

>      261 |         struct trace_event_raw_##call __maybe_unused *entry;            \
>          |                ^~~~~~~~~~~~~~~~
>    include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>       40 |         DECLARE_EVENT_CLASS(name,                              \
>          |         ^~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: note: in expansion of macro 'TRACE_EVENT'
>       31 | TRACE_EVENT(brcmf_err,
>          | ^~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_get_offsets_brcmf_dbg':
> >> include/trace/trace_events.h:261:16: warning: function 'trace_event_get_offsets_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]  

 2. "might be a candidate for 'gnu_printf' format attribute"

>      261 |         struct trace_event_raw_##call __maybe_unused *entry;            \
>          |                ^~~~~~~~~~~~~~~~
>    include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>       40 |         DECLARE_EVENT_CLASS(name,                              \
>          |         ^~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: note: in expansion of macro 'TRACE_EVENT'
>       45 | TRACE_EVENT(brcmf_dbg,
>          | ^~~~~~~~~~~
>    In file included from include/trace/define_trace.h:102,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_raw_event_brcmf_err':
>    include/trace/trace_events.h:386:16: warning: function 'trace_event_raw_event_brcmf_err' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

 3. "might be a candidate for 'gnu_printf' format attribute"

>      386 |         struct trace_event_raw_##call *entry;                           \
>          |                ^~~~~~~~~~~~~~~~
>    include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>       40 |         DECLARE_EVENT_CLASS(name,                              \
>          |         ^~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: note: in expansion of macro 'TRACE_EVENT'
>       31 | TRACE_EVENT(brcmf_err,
>          | ^~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_raw_event_brcmf_dbg':
>    include/trace/trace_events.h:386:16: warning: function 'trace_event_raw_event_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

 4. "might be a candidate for 'gnu_printf' format attribute"

>      386 |         struct trace_event_raw_##call *entry;                           \
>          |                ^~~~~~~~~~~~~~~~
>    include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>       40 |         DECLARE_EVENT_CLASS(name,                              \
>          |         ^~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: note: in expansion of macro 'TRACE_EVENT'
>       45 | TRACE_EVENT(brcmf_dbg,
>          | ^~~~~~~~~~~
>    In file included from include/trace/define_trace.h:103,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'perf_trace_brcmf_err':
>    include/trace/perf.h:64:16: warning: function 'perf_trace_brcmf_err' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

 5. "might be a candidate for 'gnu_printf' format attribute"

>       64 |         struct hlist_head *head;                                        \
>          |                ^~~~~~~~~~
>    include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>       40 |         DECLARE_EVENT_CLASS(name,                              \
>          |         ^~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: note: in expansion of macro 'TRACE_EVENT'
>       31 | TRACE_EVENT(brcmf_err,
>          | ^~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'perf_trace_brcmf_dbg':
>    include/trace/perf.h:64:16: warning: function 'perf_trace_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

 6. "might be a candidate for 'gnu_printf' format attribute"

>       64 |         struct hlist_head *head;                                        \
>          |                ^~~~~~~~~~
>    include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>       40 |         DECLARE_EVENT_CLASS(name,                              \
>          |         ^~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: note: in expansion of macro 'TRACE_EVENT'
>       45 | TRACE_EVENT(brcmf_dbg,
>          | ^~~~~~~~~~~
> --
>    In file included from include/trace/define_trace.h:102,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22:
>    drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: In function 'trace_event_get_offsets_brcms_dbg':
> >> include/trace/trace_events.h:261:16: warning: function 'trace_event_get_offsets_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]  

 7. "might be a candidate for 'gnu_printf' format attribute"

>      261 |         struct trace_event_raw_##call __maybe_unused *entry;            \
>          |                ^~~~~~~~~~~~~~~~
>    include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>       40 |         DECLARE_EVENT_CLASS(name,                              \
>          |         ^~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: note: in expansion of macro 'TRACE_EVENT'
>       59 | TRACE_EVENT(brcms_dbg,
>          | ^~~~~~~~~~~
>    In file included from include/trace/define_trace.h:102,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22:
>    drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: In function 'trace_event_raw_event_brcms_dbg':
>    include/trace/trace_events.h:386:16: warning: function 'trace_event_raw_event_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

 8. "might be a candidate for 'gnu_printf' format attribute"


>      386 |         struct trace_event_raw_##call *entry;                           \
>          |                ^~~~~~~~~~~~~~~~
>    include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>       40 |         DECLARE_EVENT_CLASS(name,                              \
>          |         ^~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: note: in expansion of macro 'TRACE_EVENT'
>       59 | TRACE_EVENT(brcms_dbg,
>          | ^~~~~~~~~~~
>    In file included from include/trace/define_trace.h:103,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38,
>                     from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22:
>    drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: In function 'perf_trace_brcms_dbg':
>    include/trace/perf.h:64:16: warning: function 'perf_trace_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

 9. "might be a candidate for 'gnu_printf' format attribute"

>       64 |         struct hlist_head *head;                                        \
>          |                ^~~~~~~~~~
>    include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>       40 |         DECLARE_EVENT_CLASS(name,                              \
>          |         ^~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: note: in expansion of macro 'TRACE_EVENT'
>       59 | TRACE_EVENT(brcms_dbg,
>          | ^~~~~~~~~~~
> 
> 
> vim +261 include/trace/trace_events.h
> 
> 55de2c0b5610cb include/trace/trace_events.h Masami Hiramatsu         2021-11-22  253  
> 091ad3658e3c76 include/trace/ftrace.h       Ingo Molnar              2009-11-26  254  #undef DECLARE_EVENT_CLASS
> 091ad3658e3c76 include/trace/ftrace.h       Ingo Molnar              2009-11-26  255  #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
> d0ee8f4a1f5f3d include/trace/trace_events.h Steven Rostedt (Red Hat  2015-05-13  256) static inline notrace int trace_event_get_offsets_##call(		\
> 62323a148fbeb0 include/trace/trace_events.h Steven Rostedt (Red Hat  2015-05-13  257) 	struct trace_event_data_offsets_##call *__data_offsets, proto)	\
> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  258  {									\
> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  259  	int __data_size = 0;						\
> 114e7b52dee69c include/trace/ftrace.h       Filipe Brandenburger     2014-02-28  260  	int __maybe_unused __item_length;				\
> a7237765730a10 include/trace/trace_events.h Steven Rostedt (Red Hat  2015-05-13 @261) 	struct trace_event_raw_##call __maybe_unused *entry;		\
> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  262  									\
> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  263  	tstruct;							\
> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  264  									\
> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  265  	return __data_size;						\
> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  266  }
> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  267  
> 

Really? 9 warnings about something that *MIGHT* be a candidate for
gnu_printf format attribute?  This is a macro that expanded into something
that could possibly use the printf format, but is nested deep in macro
magic.

Can we please shut this up?

Thanks,

-- Steve
Arend Van Spriel July 6, 2022, 9:09 a.m. UTC | #3
On 7/6/2022 4:50 AM, Steven Rostedt wrote:
> On Wed, 6 Jul 2022 10:35:50 +0800
> kernel test robot <lkp@intel.com> wrote:
> 
>> Hi Steven,
>>
>> Thank you for the patch! Perhaps something to improve:
>>
>> [auto build test WARNING on rostedt-trace/for-next]
>> [also build test WARNING on wireless-next/main wireless/main linus/master v5.19-rc5 next-20220705]
>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>> And when submitting patch, we suggest to use '--base' as documented in
>> https://git-scm.com/docs/git-format-patch]
>>
> 
> 
>> If you fix the issue, kindly add following tag where applicable
>> Reported-by: kernel test robot <lkp@intel.com>
>>
>> All warnings (new ones prefixed by >>):
> 
> OK, let's look at all the warnings.
> 
>>
>>     In file included from include/trace/define_trace.h:102,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_get_offsets_brcmf_err':
>>>> include/trace/trace_events.h:261:16: warning: function 'trace_event_get_offsets_brcmf_err' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
>   1. "might be a candidate for 'gnu_printf' format attribute"
> 
>>       261 |         struct trace_event_raw_##call __maybe_unused *entry;            \
>>           |                ^~~~~~~~~~~~~~~~
>>     include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>>        40 |         DECLARE_EVENT_CLASS(name,                              \
>>           |         ^~~~~~~~~~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: note: in expansion of macro 'TRACE_EVENT'
>>        31 | TRACE_EVENT(brcmf_err,
>>           | ^~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_get_offsets_brcmf_dbg':
>>>> include/trace/trace_events.h:261:16: warning: function 'trace_event_get_offsets_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
>   2. "might be a candidate for 'gnu_printf' format attribute"
> 
>>       261 |         struct trace_event_raw_##call __maybe_unused *entry;            \
>>           |                ^~~~~~~~~~~~~~~~
>>     include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>>        40 |         DECLARE_EVENT_CLASS(name,                              \
>>           |         ^~~~~~~~~~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: note: in expansion of macro 'TRACE_EVENT'
>>        45 | TRACE_EVENT(brcmf_dbg,
>>           | ^~~~~~~~~~~
>>     In file included from include/trace/define_trace.h:102,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_raw_event_brcmf_err':
>>     include/trace/trace_events.h:386:16: warning: function 'trace_event_raw_event_brcmf_err' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
>   3. "might be a candidate for 'gnu_printf' format attribute"
> 
>>       386 |         struct trace_event_raw_##call *entry;                           \
>>           |                ^~~~~~~~~~~~~~~~
>>     include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>>        40 |         DECLARE_EVENT_CLASS(name,                              \
>>           |         ^~~~~~~~~~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: note: in expansion of macro 'TRACE_EVENT'
>>        31 | TRACE_EVENT(brcmf_err,
>>           | ^~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'trace_event_raw_event_brcmf_dbg':
>>     include/trace/trace_events.h:386:16: warning: function 'trace_event_raw_event_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
>   4. "might be a candidate for 'gnu_printf' format attribute"
> 
>>       386 |         struct trace_event_raw_##call *entry;                           \
>>           |                ^~~~~~~~~~~~~~~~
>>     include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>>        40 |         DECLARE_EVENT_CLASS(name,                              \
>>           |         ^~~~~~~~~~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: note: in expansion of macro 'TRACE_EVENT'
>>        45 | TRACE_EVENT(brcmf_dbg,
>>           | ^~~~~~~~~~~
>>     In file included from include/trace/define_trace.h:103,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'perf_trace_brcmf_err':
>>     include/trace/perf.h:64:16: warning: function 'perf_trace_brcmf_err' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
>   5. "might be a candidate for 'gnu_printf' format attribute"
> 
>>        64 |         struct hlist_head *head;                                        \
>>           |                ^~~~~~~~~~
>>     include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>>        40 |         DECLARE_EVENT_CLASS(name,                              \
>>           |         ^~~~~~~~~~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: note: in expansion of macro 'TRACE_EVENT'
>>        31 | TRACE_EVENT(brcmf_err,
>>           | ^~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: In function 'perf_trace_brcmf_dbg':
>>     include/trace/perf.h:64:16: warning: function 'perf_trace_brcmf_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
>   6. "might be a candidate for 'gnu_printf' format attribute"
> 
>>        64 |         struct hlist_head *head;                                        \
>>           |                ^~~~~~~~~~
>>     include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>>        40 |         DECLARE_EVENT_CLASS(name,                              \
>>           |         ^~~~~~~~~~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: note: in expansion of macro 'TRACE_EVENT'
>>        45 | TRACE_EVENT(brcmf_dbg,
>>           | ^~~~~~~~~~~
>> --
>>     In file included from include/trace/define_trace.h:102,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22:
>>     drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: In function 'trace_event_get_offsets_brcms_dbg':
>>>> include/trace/trace_events.h:261:16: warning: function 'trace_event_get_offsets_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
>   7. "might be a candidate for 'gnu_printf' format attribute"
> 
>>       261 |         struct trace_event_raw_##call __maybe_unused *entry;            \
>>           |                ^~~~~~~~~~~~~~~~
>>     include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>>        40 |         DECLARE_EVENT_CLASS(name,                              \
>>           |         ^~~~~~~~~~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: note: in expansion of macro 'TRACE_EVENT'
>>        59 | TRACE_EVENT(brcms_dbg,
>>           | ^~~~~~~~~~~
>>     In file included from include/trace/define_trace.h:102,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22:
>>     drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: In function 'trace_event_raw_event_brcms_dbg':
>>     include/trace/trace_events.h:386:16: warning: function 'trace_event_raw_event_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
>   8. "might be a candidate for 'gnu_printf' format attribute"
> 
> 
>>       386 |         struct trace_event_raw_##call *entry;                           \
>>           |                ^~~~~~~~~~~~~~~~
>>     include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>>        40 |         DECLARE_EVENT_CLASS(name,                              \
>>           |         ^~~~~~~~~~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: note: in expansion of macro 'TRACE_EVENT'
>>        59 | TRACE_EVENT(brcms_dbg,
>>           | ^~~~~~~~~~~
>>     In file included from include/trace/define_trace.h:103,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38,
>>                      from drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22:
>>     drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: In function 'perf_trace_brcms_dbg':
>>     include/trace/perf.h:64:16: warning: function 'perf_trace_brcms_dbg' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
>   9. "might be a candidate for 'gnu_printf' format attribute"
> 
>>        64 |         struct hlist_head *head;                                        \
>>           |                ^~~~~~~~~~
>>     include/trace/trace_events.h:40:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
>>        40 |         DECLARE_EVENT_CLASS(name,                              \
>>           |         ^~~~~~~~~~~~~~~~~~~
>>     drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: note: in expansion of macro 'TRACE_EVENT'
>>        59 | TRACE_EVENT(brcms_dbg,
>>           | ^~~~~~~~~~~
>>
>>
>> vim +261 include/trace/trace_events.h
>>
>> 55de2c0b5610cb include/trace/trace_events.h Masami Hiramatsu         2021-11-22  253
>> 091ad3658e3c76 include/trace/ftrace.h       Ingo Molnar              2009-11-26  254  #undef DECLARE_EVENT_CLASS
>> 091ad3658e3c76 include/trace/ftrace.h       Ingo Molnar              2009-11-26  255  #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
>> d0ee8f4a1f5f3d include/trace/trace_events.h Steven Rostedt (Red Hat  2015-05-13  256) static inline notrace int trace_event_get_offsets_##call(		\
>> 62323a148fbeb0 include/trace/trace_events.h Steven Rostedt (Red Hat  2015-05-13  257) 	struct trace_event_data_offsets_##call *__data_offsets, proto)	\
>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  258  {									\
>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  259  	int __data_size = 0;						\
>> 114e7b52dee69c include/trace/ftrace.h       Filipe Brandenburger     2014-02-28  260  	int __maybe_unused __item_length;				\
>> a7237765730a10 include/trace/trace_events.h Steven Rostedt (Red Hat  2015-05-13 @261) 	struct trace_event_raw_##call __maybe_unused *entry;		\
>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  262  									\
>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  263  	tstruct;							\
>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  264  									\
>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  265  	return __data_size;						\
>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  266  }
>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 2009-06-01  267
>>
> 
> Really? 9 warnings about something that *MIGHT* be a candidate for
> gnu_printf format attribute?  This is a macro that expanded into something
> that could possibly use the printf format, but is nested deep in macro
> magic.
> 
> Can we please shut this up?

Need a vote? Here it is: +1

Regards,
Arend
Chen, Rong A July 6, 2022, 11:51 a.m. UTC | #4
On 7/6/2022 5:09 PM, Arend Van Spriel wrote:
> On 7/6/2022 4:50 AM, Steven Rostedt wrote:
>> On Wed, 6 Jul 2022 10:35:50 +0800
>> kernel test robot <lkp@intel.com> wrote:
>>
>>> Hi Steven,
>>>
>>> Thank you for the patch! Perhaps something to improve:
>>>
>>> [auto build test WARNING on rostedt-trace/for-next]
>>> [also build test WARNING on wireless-next/main wireless/main 
>>> linus/master v5.19-rc5 next-20220705]
>>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>>> And when submitting patch, we suggest to use '--base' as documented in
>>> https://git-scm.com/docs/git-format-patch]
>>>
>>
>>
>>> If you fix the issue, kindly add following tag where applicable
>>> Reported-by: kernel test robot <lkp@intel.com>
>>>
>>> All warnings (new ones prefixed by >>):
>>
>> OK, let's look at all the warnings.
>>
>>>
>>>     In file included from include/trace/define_trace.h:102,
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
>>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: 
>>> In function 'trace_event_get_offsets_brcmf_err':
>>>>> include/trace/trace_events.h:261:16: warning: function 
>>>>> 'trace_event_get_offsets_brcmf_err' might be a candidate for 
>>>>> 'gnu_printf' format attribute [-Wsuggest-attribute=format]
>>
>>   1. "might be a candidate for 'gnu_printf' format attribute"
>>
>>>       261 |         struct trace_event_raw_##call __maybe_unused 
>>> *entry;            \
>>>           |                ^~~~~~~~~~~~~~~~
>>>     include/trace/trace_events.h:40:9: note: in expansion of macro 
>>> 'DECLARE_EVENT_CLASS'
>>>        40 |         
>>> DECLARE_EVENT_CLASS(name,                              \
>>>           |         ^~~~~~~~~~~~~~~~~~~
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: 
>>> note: in expansion of macro 'TRACE_EVENT'
>>>        31 | TRACE_EVENT(brcmf_err,
>>>           | ^~~~~~~~~~~
>>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: 
>>> In function 'trace_event_get_offsets_brcmf_dbg':
>>>>> include/trace/trace_events.h:261:16: warning: function 
>>>>> 'trace_event_get_offsets_brcmf_dbg' might be a candidate for 
>>>>> 'gnu_printf' format attribute [-Wsuggest-attribute=format]
>>
>>   2. "might be a candidate for 'gnu_printf' format attribute"
>>
>>>       261 |         struct trace_event_raw_##call __maybe_unused 
>>> *entry;            \
>>>           |                ^~~~~~~~~~~~~~~~
>>>     include/trace/trace_events.h:40:9: note: in expansion of macro 
>>> 'DECLARE_EVENT_CLASS'
>>>        40 |         
>>> DECLARE_EVENT_CLASS(name,                              \
>>>           |         ^~~~~~~~~~~~~~~~~~~
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: 
>>> note: in expansion of macro 'TRACE_EVENT'
>>>        45 | TRACE_EVENT(brcmf_dbg,
>>>           | ^~~~~~~~~~~
>>>     In file included from include/trace/define_trace.h:102,
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
>>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: 
>>> In function 'trace_event_raw_event_brcmf_err':
>>>     include/trace/trace_events.h:386:16: warning: function 
>>> 'trace_event_raw_event_brcmf_err' might be a candidate for 
>>> 'gnu_printf' format attribute [-Wsuggest-attribute=format]
>>
>>   3. "might be a candidate for 'gnu_printf' format attribute"
>>
>>>       386 |         struct trace_event_raw_##call 
>>> *entry;                           \
>>>           |                ^~~~~~~~~~~~~~~~
>>>     include/trace/trace_events.h:40:9: note: in expansion of macro 
>>> 'DECLARE_EVENT_CLASS'
>>>        40 |         
>>> DECLARE_EVENT_CLASS(name,                              \
>>>           |         ^~~~~~~~~~~~~~~~~~~
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: 
>>> note: in expansion of macro 'TRACE_EVENT'
>>>        31 | TRACE_EVENT(brcmf_err,
>>>           | ^~~~~~~~~~~
>>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: 
>>> In function 'trace_event_raw_event_brcmf_dbg':
>>>     include/trace/trace_events.h:386:16: warning: function 
>>> 'trace_event_raw_event_brcmf_dbg' might be a candidate for 
>>> 'gnu_printf' format attribute [-Wsuggest-attribute=format]
>>
>>   4. "might be a candidate for 'gnu_printf' format attribute"
>>
>>>       386 |         struct trace_event_raw_##call 
>>> *entry;                           \
>>>           |                ^~~~~~~~~~~~~~~~
>>>     include/trace/trace_events.h:40:9: note: in expansion of macro 
>>> 'DECLARE_EVENT_CLASS'
>>>        40 |         
>>> DECLARE_EVENT_CLASS(name,                              \
>>>           |         ^~~~~~~~~~~~~~~~~~~
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: 
>>> note: in expansion of macro 'TRACE_EVENT'
>>>        45 | TRACE_EVENT(brcmf_dbg,
>>>           | ^~~~~~~~~~~
>>>     In file included from include/trace/define_trace.h:103,
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h:133,
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:12:
>>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: 
>>> In function 'perf_trace_brcmf_err':
>>>     include/trace/perf.h:64:16: warning: function 
>>> 'perf_trace_brcmf_err' might be a candidate for 'gnu_printf' format 
>>> attribute [-Wsuggest-attribute=format]
>>
>>   5. "might be a candidate for 'gnu_printf' format attribute"
>>
>>>        64 |         struct hlist_head 
>>> *head;                                        \
>>>           |                ^~~~~~~~~~
>>>     include/trace/trace_events.h:40:9: note: in expansion of macro 
>>> 'DECLARE_EVENT_CLASS'
>>>        40 |         
>>> DECLARE_EVENT_CLASS(name,                              \
>>>           |         ^~~~~~~~~~~~~~~~~~~
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:31:1: 
>>> note: in expansion of macro 'TRACE_EVENT'
>>>        31 | TRACE_EVENT(brcmf_err,
>>>           | ^~~~~~~~~~~
>>>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h: 
>>> In function 'perf_trace_brcmf_dbg':
>>>     include/trace/perf.h:64:16: warning: function 
>>> 'perf_trace_brcmf_dbg' might be a candidate for 'gnu_printf' format 
>>> attribute [-Wsuggest-attribute=format]
>>
>>   6. "might be a candidate for 'gnu_printf' format attribute"
>>
>>>        64 |         struct hlist_head 
>>> *head;                                        \
>>>           |                ^~~~~~~~~~
>>>     include/trace/trace_events.h:40:9: note: in expansion of macro 
>>> 'DECLARE_EVENT_CLASS'
>>>        40 |         
>>> DECLARE_EVENT_CLASS(name,                              \
>>>           |         ^~~~~~~~~~~~~~~~~~~
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/./tracepoint.h:45:1: 
>>> note: in expansion of macro 'TRACE_EVENT'
>>>        45 | TRACE_EVENT(brcmf_dbg,
>>>           | ^~~~~~~~~~~
>>> -- 
>>>     In file included from include/trace/define_trace.h:102,
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82, 
>>>
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38, 
>>>
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22: 
>>>
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: 
>>> In function 'trace_event_get_offsets_brcms_dbg':
>>>>> include/trace/trace_events.h:261:16: warning: function 
>>>>> 'trace_event_get_offsets_brcms_dbg' might be a candidate for 
>>>>> 'gnu_printf' format attribute [-Wsuggest-attribute=format]
>>
>>   7. "might be a candidate for 'gnu_printf' format attribute"
>>
>>>       261 |         struct trace_event_raw_##call __maybe_unused 
>>> *entry;            \
>>>           |                ^~~~~~~~~~~~~~~~
>>>     include/trace/trace_events.h:40:9: note: in expansion of macro 
>>> 'DECLARE_EVENT_CLASS'
>>>        40 |         
>>> DECLARE_EVENT_CLASS(name,                              \
>>>           |         ^~~~~~~~~~~~~~~~~~~
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: 
>>> note: in expansion of macro 'TRACE_EVENT'
>>>        59 | TRACE_EVENT(brcms_dbg,
>>>           | ^~~~~~~~~~~
>>>     In file included from include/trace/define_trace.h:102,
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82, 
>>>
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38, 
>>>
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22: 
>>>
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: 
>>> In function 'trace_event_raw_event_brcms_dbg':
>>>     include/trace/trace_events.h:386:16: warning: function 
>>> 'trace_event_raw_event_brcms_dbg' might be a candidate for 
>>> 'gnu_printf' format attribute [-Wsuggest-attribute=format]
>>
>>   8. "might be a candidate for 'gnu_printf' format attribute"
>>
>>
>>>       386 |         struct trace_event_raw_##call 
>>> *entry;                           \
>>>           |                ^~~~~~~~~~~~~~~~
>>>     include/trace/trace_events.h:40:9: note: in expansion of macro 
>>> 'DECLARE_EVENT_CLASS'
>>>        40 |         
>>> DECLARE_EVENT_CLASS(name,                              \
>>>           |         ^~~~~~~~~~~~~~~~~~~
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: 
>>> note: in expansion of macro 'TRACE_EVENT'
>>>        59 | TRACE_EVENT(brcms_dbg,
>>>           | ^~~~~~~~~~~
>>>     In file included from include/trace/define_trace.h:103,
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h:82, 
>>>
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.h:38, 
>>>
>>>                      from 
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_events.c:22: 
>>>
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h: 
>>> In function 'perf_trace_brcms_dbg':
>>>     include/trace/perf.h:64:16: warning: function 
>>> 'perf_trace_brcms_dbg' might be a candidate for 'gnu_printf' format 
>>> attribute [-Wsuggest-attribute=format]
>>
>>   9. "might be a candidate for 'gnu_printf' format attribute"
>>
>>>        64 |         struct hlist_head 
>>> *head;                                        \
>>>           |                ^~~~~~~~~~
>>>     include/trace/trace_events.h:40:9: note: in expansion of macro 
>>> 'DECLARE_EVENT_CLASS'
>>>        40 |         
>>> DECLARE_EVENT_CLASS(name,                              \
>>>           |         ^~~~~~~~~~~~~~~~~~~
>>>     
>>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/./brcms_trace_brcmsmac_msg.h:59:1: 
>>> note: in expansion of macro 'TRACE_EVENT'
>>>        59 | TRACE_EVENT(brcms_dbg,
>>>           | ^~~~~~~~~~~
>>>
>>>
>>> vim +261 include/trace/trace_events.h
>>>
>>> 55de2c0b5610cb include/trace/trace_events.h Masami Hiramatsu         
>>> 2021-11-22  253
>>> 091ad3658e3c76 include/trace/ftrace.h       Ingo Molnar              
>>> 2009-11-26  254  #undef DECLARE_EVENT_CLASS
>>> 091ad3658e3c76 include/trace/ftrace.h       Ingo Molnar              
>>> 2009-11-26  255  #define DECLARE_EVENT_CLASS(call, proto, args, 
>>> tstruct, assign, print)    \
>>> d0ee8f4a1f5f3d include/trace/trace_events.h Steven Rostedt (Red Hat  
>>> 2015-05-13  256) static inline notrace int 
>>> trace_event_get_offsets_##call(        \
>>> 62323a148fbeb0 include/trace/trace_events.h Steven Rostedt (Red Hat  
>>> 2015-05-13  257)     struct trace_event_data_offsets_##call 
>>> *__data_offsets, proto)    \
>>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 
>>> 2009-06-01  258  {                                    \
>>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 
>>> 2009-06-01  259      int __data_size = 0;                        \
>>> 114e7b52dee69c include/trace/ftrace.h       Filipe Brandenburger     
>>> 2014-02-28  260      int __maybe_unused __item_length;                \
>>> a7237765730a10 include/trace/trace_events.h Steven Rostedt (Red Hat  
>>> 2015-05-13 @261)     struct trace_event_raw_##call __maybe_unused 
>>> *entry;        \
>>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 
>>> 2009-06-01  262                                      \
>>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 
>>> 2009-06-01  263      tstruct;                            \
>>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 
>>> 2009-06-01  264                                      \
>>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 
>>> 2009-06-01  265      return __data_size;                        \
>>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 
>>> 2009-06-01  266  }
>>> 7fcb7c472f455d include/trace/ftrace.h       Li Zefan                 
>>> 2009-06-01  267
>>>
>>
>> Really? 9 warnings about something that *MIGHT* be a candidate for
>> gnu_printf format attribute?  This is a macro that expanded into 
>> something
>> that could possibly use the printf format, but is nested deep in macro
>> magic.
>>
>> Can we please shut this up?
> 
> Need a vote? Here it is: +1
> 
> Regards,
> Arend
> 

Hi,

Sorry for the noise, we'll stop reporting this warning next time.

Best Regards,
Rong Chen
Kalle Valo July 8, 2022, 5:02 a.m. UTC | #5
Steven Rostedt <rostedt@goodmis.org> writes:

> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> Instead of open coding a __dynamic_array() with a fixed length (which
> defeats the purpose of the dynamic array in the first place). Use the new
> __vstring() helper that will use a va_list and only write enough of the
> string into the ring buffer that is needed.
>
> Cc: Arend van Spriel <aspriel@gmail.com>
> Cc: Franky Lin <franky.lin@broadcom.com>
> Cc: Hante Meuleman <hante.meuleman@broadcom.com>
> Cc: Kalle Valo <kvalo@kernel.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: linux-wireless@vger.kernel.org
> Cc: brcm80211-dev-list.pdl@broadcom.com
> Cc: SHA-cyfmac-dev-list@infineon.com
> Cc: netdev@vger.kernel.org
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>  .../broadcom/brcm80211/brcmfmac/tracepoint.h         | 12 ++++--------
>  .../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h    | 12 ++++--------
>  2 files changed, 8 insertions(+), 16 deletions(-)

Feel free to take this via your tree:

Acked-by: Kalle Valo <kvalo@kernel.org>
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h
index 338c66d0c5f8..5a139d7ed47a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h
@@ -33,13 +33,11 @@  TRACE_EVENT(brcmf_err,
 	TP_ARGS(func, vaf),
 	TP_STRUCT__entry(
 		__string(func, func)
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(func, func);
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(func), __get_str(msg))
 );
@@ -50,14 +48,12 @@  TRACE_EVENT(brcmf_dbg,
 	TP_STRUCT__entry(
 		__field(u32, level)
 		__string(func, func)
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__entry->level = level;
 		__assign_str(func, func);
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(func), __get_str(msg))
 );
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h
index 0e8a69ab909f..488456420353 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h
@@ -28,12 +28,10 @@  DECLARE_EVENT_CLASS(brcms_msg_event,
 	TP_PROTO(struct va_format *vaf),
 	TP_ARGS(vaf),
 	TP_STRUCT__entry(
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s", __get_str(msg))
 );
@@ -64,14 +62,12 @@  TRACE_EVENT(brcms_dbg,
 	TP_STRUCT__entry(
 		__field(u32, level)
 		__string(func, func)
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__entry->level = level;
 		__assign_str(func, func);
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(func), __get_str(msg))
 );