Skip to contentSkip to conversation

include/trace/events/sunrpc.h:703:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead)

PATCH kernel test robot 3 participants 8 messages Feb 29, 2024 – Mar 1, 2024 Tracing

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace trace/for-next
head:   eb1533d156d307c2125943eaf1925e268094d984
commit: 433e1d88a3be93222989e52fa99594fe9eb93622 [28/29] tracing: Add warning if string in __assign_str() does not match __string()
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20240229/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240229/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from net/sunrpc/sched.c:31:
In file included from include/trace/events/sunrpc.h:2520:
In file included from include/trace/define_trace.h:102:
In file included from include/trace/trace_events.h:419:

>> include/trace/events/sunrpc.h:703:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
     663 |                         __assign_str(progname,
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     664 |                                      task->tk_client->cl_program->name);
         |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     665 |                         __entry->version = task->tk_client->cl_vers;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     666 |                         __assign_str(procedure, task->tk_msg.rpc_proc->p_name);
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     667 |                 } else {
         |                 ~~~~~~~~
     668 |                         __entry->task_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     669 |                         __entry->client_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~
     670 |                         __assign_str(progname, "unknown");
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     671 |                         __entry->version = 0;
         |                         ~~~~~~~~~~~~~~~~~~~~~
     672 |                         __assign_str(procedure, "unknown");
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     673 |                 }
         |                 ~
     674 |                 __entry->requested = requested;
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     675 |                 __entry->end = xdr->end;
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~
     676 |                 __entry->p = xdr->p;
         |                 ~~~~~~~~~~~~~~~~~~~~
     677 |                 __entry->head_base = xdr->buf->head[0].iov_base,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     678 |                 __entry->head_len = xdr->buf->head[0].iov_len,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/trace/stages/stage6_event_callback.h:38:22: note: expanded from macro '__assign_str'
      38 |                 WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);       \
         |                                    ^
   include/asm-generic/bug.h:111:25: note: expanded from macro 'WARN_ON_ONCE'
     111 |         int __ret_warn_on = !!(condition);                      \
         |                                ^
   include/trace/stages/stage6_event_callback.h:134:33: note: expanded from macro 'TP_fast_assign'
     134 | #define TP_fast_assign(args...) args
         |                                 ^
   include/trace/trace_events.h:44:16: note: expanded from macro 'TRACE_EVENT'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      41 |                              PARAMS(proto),                    \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      42 |                              PARAMS(args),                     \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      43 |                              PARAMS(tstruct),                  \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      44 |                              PARAMS(assign),                   \
         |                              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      45 |                              PARAMS(print));                   \
         |                              ~~~~~~~~~~~~~~
   include/linux/tracepoint.h:107:25: note: expanded from macro 'PARAMS'
     107 | #define PARAMS(args...) args
         |                         ^
   include/trace/trace_events.h:402:4: note: expanded from macro 'DECLARE_EVENT_CLASS'
     402 |         { assign; }                                                     \
         |           ^~~~~~
   In file included from net/sunrpc/sched.c:31:
   In file included from include/trace/events/sunrpc.h:2520:
   In file included from include/trace/define_trace.h:102:
   In file included from include/trace/trace_events.h:419:
   include/trace/events/sunrpc.h:705:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
     663 |                         __entry->version = task->tk_client->cl_vers;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     664 |                         __assign_str(procedure, task->tk_msg.rpc_proc->p_name);
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     665 |                 } else {
         |                 ~~~~~~~~
     666 |                         __entry->task_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     667 |                         __entry->client_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~
     668 |                         __assign_str(progname, "unknown");
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     669 |                         __entry->version = 0;
         |                         ~~~~~~~~~~~~~~~~~~~~~
     670 |                         __assign_str(procedure, "unknown");
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     671 |                 }
         |                 ~
     672 |                 __entry->requested = requested;
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     673 |                 __entry->end = xdr->end;
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~
     674 |                 __entry->p = xdr->p;
         |                 ~~~~~~~~~~~~~~~~~~~~
     675 |                 __entry->head_base = xdr->buf->head[0].iov_base,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     676 |                 __entry->head_len = xdr->buf->head[0].iov_len,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     677 |                 __entry->page_len = xdr->buf->page_len,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     678 |                 __entry->tail_base = xdr->buf->tail[0].iov_base,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/trace/stages/stage6_event_callback.h:38:22: note: expanded from macro '__assign_str'
      38 |                 WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);       \
         |                                    ^
   include/asm-generic/bug.h:111:25: note: expanded from macro 'WARN_ON_ONCE'
     111 |         int __ret_warn_on = !!(condition);                      \
         |                                ^
   include/trace/stages/stage6_event_callback.h:134:33: note: expanded from macro 'TP_fast_assign'
     134 | #define TP_fast_assign(args...) args
         |                                 ^
   include/trace/trace_events.h:44:16: note: expanded from macro 'TRACE_EVENT'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      41 |                              PARAMS(proto),                    \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      42 |                              PARAMS(args),                     \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      43 |                              PARAMS(tstruct),                  \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      44 |                              PARAMS(assign),                   \
         |                              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      45 |                              PARAMS(print));                   \
         |                              ~~~~~~~~~~~~~~
   include/linux/tracepoint.h:107:25: note: expanded from macro 'PARAMS'
     107 | #define PARAMS(args...) args
         |                         ^
   include/trace/trace_events.h:402:4: note: expanded from macro 'DECLARE_EVENT_CLASS'
     402 |         { assign; }                                                     \
         |           ^~~~~~
   In file included from net/sunrpc/sched.c:31:
   In file included from include/trace/events/sunrpc.h:2520:
   In file included from include/trace/define_trace.h:103:
   In file included from include/trace/perf.h:75:
>> include/trace/events/sunrpc.h:703:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
     663 |                         __assign_str(progname,
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     664 |                                      task->tk_client->cl_program->name);
         |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     665 |                         __entry->version = task->tk_client->cl_vers;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     666 |                         __assign_str(procedure, task->tk_msg.rpc_proc->p_name);
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     667 |                 } else {
         |                 ~~~~~~~~
     668 |                         __entry->task_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     669 |                         __entry->client_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~
     670 |                         __assign_str(progname, "unknown");
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     671 |                         __entry->version = 0;
         |                         ~~~~~~~~~~~~~~~~~~~~~
     672 |                         __assign_str(procedure, "unknown");
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     673 |                 }
         |                 ~
     674 |                 __entry->requested = requested;
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     675 |                 __entry->end = xdr->end;
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~
     676 |                 __entry->p = xdr->p;
         |                 ~~~~~~~~~~~~~~~~~~~~
     677 |                 __entry->head_base = xdr->buf->head[0].iov_base,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     678 |                 __entry->head_len = xdr->buf->head[0].iov_len,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/trace/stages/stage6_event_callback.h:38:22: note: expanded from macro '__assign_str'
      38 |                 WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);       \
         |                                    ^
   include/asm-generic/bug.h:111:25: note: expanded from macro 'WARN_ON_ONCE'
     111 |         int __ret_warn_on = !!(condition);                      \
         |                                ^
   include/trace/stages/stage6_event_callback.h:134:33: note: expanded from macro 'TP_fast_assign'
     134 | #define TP_fast_assign(args...) args
         |                                 ^
   include/trace/trace_events.h:44:16: note: expanded from macro 'TRACE_EVENT'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      41 |                              PARAMS(proto),                    \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      42 |                              PARAMS(args),                     \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      43 |                              PARAMS(tstruct),                  \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      44 |                              PARAMS(assign),                   \
         |                              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      45 |                              PARAMS(print));                   \
         |                              ~~~~~~~~~~~~~~
   include/linux/tracepoint.h:107:25: note: expanded from macro 'PARAMS'
     107 | #define PARAMS(args...) args
         |                         ^
   include/trace/perf.h:51:4: note: expanded from macro 'DECLARE_EVENT_CLASS'
      51 |         { assign; }                                                     \
         |           ^~~~~~
   In file included from net/sunrpc/sched.c:31:
   In file included from include/trace/events/sunrpc.h:2520:
   In file included from include/trace/define_trace.h:103:
   In file included from include/trace/perf.h:75:
   include/trace/events/sunrpc.h:705:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
     663 |                         __entry->version = task->tk_client->cl_vers;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     664 |                         __assign_str(procedure, task->tk_msg.rpc_proc->p_name);
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     665 |                 } else {
         |                 ~~~~~~~~
     666 |                         __entry->task_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     667 |                         __entry->client_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~
     668 |                         __assign_str(progname, "unknown");
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     669 |                         __entry->version = 0;
         |                         ~~~~~~~~~~~~~~~~~~~~~
     670 |                         __assign_str(procedure, "unknown");
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     671 |                 }
         |                 ~
     672 |                 __entry->requested = requested;
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     673 |                 __entry->end = xdr->end;
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~
     674 |                 __entry->p = xdr->p;
         |                 ~~~~~~~~~~~~~~~~~~~~
     675 |                 __entry->head_base = xdr->buf->head[0].iov_base,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     676 |                 __entry->head_len = xdr->buf->head[0].iov_len,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     677 |                 __entry->page_len = xdr->buf->page_len,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     678 |                 __entry->tail_base = xdr->buf->tail[0].iov_base,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/trace/stages/stage6_event_callback.h:38:22: note: expanded from macro '__assign_str'
      38 |                 WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);       \
         |                                    ^

vim +703 include/trace/events/sunrpc.h

82b0a4c3c171b1 Trond Myklebust 2012-01-20  662  
5582863f450ca4 Chuck Lever     2019-02-11  663  TRACE_EVENT(rpc_xdr_overflow,
5582863f450ca4 Chuck Lever     2019-02-11  664  	TP_PROTO(
5582863f450ca4 Chuck Lever     2019-02-11  665  		const struct xdr_stream *xdr,
5582863f450ca4 Chuck Lever     2019-02-11  666  		size_t requested
5582863f450ca4 Chuck Lever     2019-02-11  667  	),
5582863f450ca4 Chuck Lever     2019-02-11  668  
5582863f450ca4 Chuck Lever     2019-02-11  669  	TP_ARGS(xdr, requested),
5582863f450ca4 Chuck Lever     2019-02-11  670  
5582863f450ca4 Chuck Lever     2019-02-11  671  	TP_STRUCT__entry(
5582863f450ca4 Chuck Lever     2019-02-11  672  		__field(unsigned int, task_id)
5582863f450ca4 Chuck Lever     2019-02-11  673  		__field(unsigned int, client_id)
5582863f450ca4 Chuck Lever     2019-02-11  674  		__field(int, version)
5582863f450ca4 Chuck Lever     2019-02-11  675  		__field(size_t, requested)
5582863f450ca4 Chuck Lever     2019-02-11  676  		__field(const void *, end)
5582863f450ca4 Chuck Lever     2019-02-11  677  		__field(const void *, p)
5582863f450ca4 Chuck Lever     2019-02-11  678  		__field(const void *, head_base)
5582863f450ca4 Chuck Lever     2019-02-11  679  		__field(size_t, head_len)
5582863f450ca4 Chuck Lever     2019-02-11  680  		__field(const void *, tail_base)
5582863f450ca4 Chuck Lever     2019-02-11  681  		__field(size_t, tail_len)
5582863f450ca4 Chuck Lever     2019-02-11  682  		__field(unsigned int, page_len)
5582863f450ca4 Chuck Lever     2019-02-11  683  		__field(unsigned int, len)
d321ff589c16d8 Chuck Lever     2020-10-23  684  		__string(progname, xdr->rqst ?
d321ff589c16d8 Chuck Lever     2020-10-23  685  			 xdr->rqst->rq_task->tk_client->cl_program->name : "unknown")
d321ff589c16d8 Chuck Lever     2020-10-23  686  		__string(procedure, xdr->rqst ?
d321ff589c16d8 Chuck Lever     2020-10-23  687  			 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name : "unknown")
5582863f450ca4 Chuck Lever     2019-02-11  688  	),
5582863f450ca4 Chuck Lever     2019-02-11  689  
5582863f450ca4 Chuck Lever     2019-02-11  690  	TP_fast_assign(
5582863f450ca4 Chuck Lever     2019-02-11  691  		if (xdr->rqst) {
5582863f450ca4 Chuck Lever     2019-02-11  692  			const struct rpc_task *task = xdr->rqst->rq_task;
5582863f450ca4 Chuck Lever     2019-02-11  693  
5582863f450ca4 Chuck Lever     2019-02-11  694  			__entry->task_id = task->tk_pid;
5582863f450ca4 Chuck Lever     2019-02-11  695  			__entry->client_id = task->tk_client->cl_clid;
5582863f450ca4 Chuck Lever     2019-02-11  696  			__assign_str(progname,
78c14b385c195d Joe Perches     2021-06-12  697  				     task->tk_client->cl_program->name);
5582863f450ca4 Chuck Lever     2019-02-11  698  			__entry->version = task->tk_client->cl_vers;
78c14b385c195d Joe Perches     2021-06-12  699  			__assign_str(procedure, task->tk_msg.rpc_proc->p_name);
5582863f450ca4 Chuck Lever     2019-02-11  700  		} else {
b4776a341ec05e Chuck Lever     2021-10-16  701  			__entry->task_id = -1;
b4776a341ec05e Chuck Lever     2021-10-16  702  			__entry->client_id = -1;
78c14b385c195d Joe Perches     2021-06-12 @703  			__assign_str(progname, "unknown");
5582863f450ca4 Chuck Lever     2019-02-11  704  			__entry->version = 0;
78c14b385c195d Joe Perches     2021-06-12  705  			__assign_str(procedure, "unknown");
5582863f450ca4 Chuck Lever     2019-02-11  706  		}
5582863f450ca4 Chuck Lever     2019-02-11  707  		__entry->requested = requested;
5582863f450ca4 Chuck Lever     2019-02-11  708  		__entry->end = xdr->end;
5582863f450ca4 Chuck Lever     2019-02-11  709  		__entry->p = xdr->p;
5582863f450ca4 Chuck Lever     2019-02-11  710  		__entry->head_base = xdr->buf->head[0].iov_base,
5582863f450ca4 Chuck Lever     2019-02-11  711  		__entry->head_len = xdr->buf->head[0].iov_len,
5582863f450ca4 Chuck Lever     2019-02-11  712  		__entry->page_len = xdr->buf->page_len,
5582863f450ca4 Chuck Lever     2019-02-11  713  		__entry->tail_base = xdr->buf->tail[0].iov_base,
5582863f450ca4 Chuck Lever     2019-02-11  714  		__entry->tail_len = xdr->buf->tail[0].iov_len,
5582863f450ca4 Chuck Lever     2019-02-11  715  		__entry->len = xdr->buf->len;
5582863f450ca4 Chuck Lever     2019-02-11  716  	),
5582863f450ca4 Chuck Lever     2019-02-11  717  
b4776a341ec05e Chuck Lever     2021-10-16  718  	TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
b4776a341ec05e Chuck Lever     2021-10-16  719  		  " %sv%d %s requested=%zu p=%p end=%p xdr=[%p,%zu]/%u/[%p,%zu]/%u\n",
5582863f450ca4 Chuck Lever     2019-02-11  720  		__entry->task_id, __entry->client_id,
5582863f450ca4 Chuck Lever     2019-02-11  721  		__get_str(progname), __entry->version, __get_str(procedure),
5582863f450ca4 Chuck Lever     2019-02-11  722  		__entry->requested, __entry->p, __entry->end,
5582863f450ca4 Chuck Lever     2019-02-11  723  		__entry->head_base, __entry->head_len,
5582863f450ca4 Chuck Lever     2019-02-11  724  		__entry->page_len,
5582863f450ca4 Chuck Lever     2019-02-11  725  		__entry->tail_base, __entry->tail_len,
5582863f450ca4 Chuck Lever     2019-02-11  726  		__entry->len
5582863f450ca4 Chuck Lever     2019-02-11  727  	)
5582863f450ca4 Chuck Lever     2019-02-11  728  );
5582863f450ca4 Chuck Lever     2019-02-11  729  

:::::: The code at line 703 was first introduced by commit
:::::: 78c14b385c195d4f25ab7c19186b8897a5b9ae3f treewide: Add missing semicolons to __assign_str uses

:::::: TO: Joe Perches <[email protected]>
:::::: CC: Steven Rostedt (VMware) <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#1 lore raw
Quoted 32 lines · On Thu, 29 Feb 2024 21:35:53 +0800 kernel test robot <[email protected]> wrote:
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace trace/for-next
head:   eb1533d156d307c2125943eaf1925e268094d984
commit: 433e1d88a3be93222989e52fa99594fe9eb93622 [28/29] tracing: Add warning if string in __assign_str() does not match __string()
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20240229/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240229/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from net/sunrpc/sched.c:31:
In file included from include/trace/events/sunrpc.h:2520:
In file included from include/trace/define_trace.h:102:
In file included from include/trace/trace_events.h:419:

Quoted 1 line
Quoted 1 line

include/trace/events/sunrpc.h:703:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]

     663 |                         __assign_str(progname,
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     664 |                                      task->tk_client->cl_program->name);
         |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     665 |                         __entry->version = task->tk_client->cl_vers;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     666 |                         __assign_str(procedure, task->tk_msg.rpc_proc->p_name);
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     667 |                 } else {
         |                 ~~~~~~~~
     668 |                         __entry->task_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     669 |                         __entry->client_id = -1;
Quoted 8 lines
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~
     670 |                         __assign_str(progname, "unknown");
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     671 |                         __entry->version = 0;
         |                         ~~~~~~~~~~~~~~~~~~~~~
     672 |                         __assign_str(procedure, "unknown");
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     673 |                 }

I don't build with clang, does this quiet the warning?

-- Steve

include/trace/stages/stage6_event_callback.h +3 -1
index a0c15f67eabe..83da83a0c14f 100644
@@ -35,7 +35,9 @@
 	do {								\
 		char *__str__ = __get_str(dst);				\
 		int __len__ = __get_dynamic_array_len(dst) - 1;		\
-		WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);	\
+		WARN_ON_ONCE(__builtin_constant_p(src) ?		\
+			     strcmp((src), __data_offsets.dst##_ptr_) :	\
+			     (src) != __data_offsets.dst##_ptr_);	\
 		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
 		       EVENT_NULL_STR, __len__);			\
 		__str__[__len__] = '\0';				\
Signature · 1 line
2.43.0
#2 lore raw

Hi Steve,

Quoted 45 lines · Steven Rostedt
Quoted 32 lines · On Thu, 29 Feb 2024 21:35:53 +0800 kernel test robot <[email protected]> wrote:
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace trace/for-next
head:   eb1533d156d307c2125943eaf1925e268094d984
commit: 433e1d88a3be93222989e52fa99594fe9eb93622 [28/29] tracing: Add warning if string in __assign_str() does not match __string()
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20240229/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240229/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from net/sunrpc/sched.c:31:
In file included from include/trace/events/sunrpc.h:2520:
In file included from include/trace/define_trace.h:102:
In file included from include/trace/trace_events.h:419:

Quoted 1 line
Quoted 1 line

include/trace/events/sunrpc.h:703:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]

     663 |                         __assign_str(progname,
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     664 |                                      task->tk_client->cl_program->name);
         |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     665 |                         __entry->version = task->tk_client->cl_vers;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     666 |                         __assign_str(procedure, task->tk_msg.rpc_proc->p_name);
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     667 |                 } else {
         |                 ~~~~~~~~
     668 |                         __entry->task_id = -1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~
     669 |                         __entry->client_id = -1;
Quoted 8 lines
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~
     670 |                         __assign_str(progname, "unknown");
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     671 |                         __entry->version = 0;
         |                         ~~~~~~~~~~~~~~~~~~~~~
     672 |                         __assign_str(procedure, "unknown");
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     673 |                 }
Quoted 1 line

I don't build with clang, does this quiet the warning?

Unfortunately, it does not. I tested with LLVM 17.0.6 from kernel.org:

https://mirrors.edge.kernel.org/pub/tools/llvm/

If there is no other way to silence it, we could potentially use the diag infrastructure to silence it, I could look at that tomorrow.

Cheers,
Nathan

Quoted 19 lines
include/trace/stages/stage6_event_callback.h +3 -1
index a0c15f67eabe..83da83a0c14f 100644
@@ -35,7 +35,9 @@
 	do {								\
 		char *__str__ = __get_str(dst);				\
 		int __len__ = __get_dynamic_array_len(dst) - 1;		\
-		WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);	\
+		WARN_ON_ONCE(__builtin_constant_p(src) ?		\
+			     strcmp((src), __data_offsets.dst##_ptr_) :	\
+			     (src) != __data_offsets.dst##_ptr_);	\
 		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
 		       EVENT_NULL_STR, __len__);			\
 		__str__[__len__] = '\0';				\
Signature · 1 line
2.43.0
maintainer
#3 lore raw
Quoted 8 lines · On Thu, 29 Feb 2024 16:44:55 -0700 Nathan Chancellor <[email protected]> wrote:
Quoted 1 line

I don't build with clang, does this quiet the warning?

Unfortunately, it does not. I tested with LLVM 17.0.6 from kernel.org:

https://mirrors.edge.kernel.org/pub/tools/llvm/

If there is no other way to silence it, we could potentially use the diag infrastructure to silence it, I could look at that tomorrow.

Is it the exact same warning? I wonder if I make it into an if statement, it would be better?

#define __assign_str(dst, src)						\
	do {								\
		char *__str__ = __get_str(dst);				\
		int __len__ = __get_dynamic_array_len(dst) - 1;		\
		if (__builtin_constant_p(src))				\
			WARN_ON_ONCE(strcmp((src), __data_offsets.dst##_ptr_)); \
		else							\
			WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);\
		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
		       EVENT_NULL_STR, __len__);			\
		__str__[__len__] = '\0';				\
	} while (0)

Then the compiler may be better in optimizing out the "bad" portion.

-- Steve

#4 lore raw
Quoted 28 lines · Steven Rostedt
Quoted 8 lines · On Thu, 29 Feb 2024 16:44:55 -0700 Nathan Chancellor <[email protected]> wrote:
Quoted 1 line

I don't build with clang, does this quiet the warning?

Unfortunately, it does not. I tested with LLVM 17.0.6 from kernel.org:

https://mirrors.edge.kernel.org/pub/tools/llvm/

If there is no other way to silence it, we could potentially use the diag infrastructure to silence it, I could look at that tomorrow.

Is it the exact same warning? I wonder if I make it into an if statement, it would be better?

#define __assign_str(dst, src)						\
	do {								\
		char *__str__ = __get_str(dst);				\
		int __len__ = __get_dynamic_array_len(dst) - 1;		\
		if (__builtin_constant_p(src))				\
			WARN_ON_ONCE(strcmp((src), __data_offsets.dst##_ptr_)); \
		else							\
			WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);\
		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
		       EVENT_NULL_STR, __len__);			\
		__str__[__len__] = '\0';				\
	} while (0)
Quoted 1 line

Then the compiler may be better in optimizing out the "bad" portion.

No, that does not work either, I diffed the warnings and they are identical minus line numbers. I don't think clang takes __builtin_constant_p() into account in the front end but I could be wrong. In fact, I think clang (and even gcc sometimes) will still warn for code even if it is within an 'if (0)' block, it's been used as justification before in commit 37b47298ab86 ("sched: Disable -Wunused-but-set-variable").

Cheers,
Nathan

maintainer
#5 lore raw
Quoted 15 lines · On Thu, 29 Feb 2024 21:11:31 -0700 Nathan Chancellor <[email protected]> wrote:
Quoted 13 lines
#define __assign_str(dst, src)						\
	do {								\
		char *__str__ = __get_str(dst);				\
		int __len__ = __get_dynamic_array_len(dst) - 1;		\
		if (__builtin_constant_p(src))				\
			WARN_ON_ONCE(strcmp((src), __data_offsets.dst##_ptr_)); \
		else							\
			WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);\
		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
		       EVENT_NULL_STR, __len__);			\
		__str__[__len__] = '\0';				\
	} while (0)
Quoted 1 line

Then the compiler may be better in optimizing out the "bad" portion.

Quoted 7 lines

No, that does not work either, I diffed the warnings and they are identical minus line numbers. I don't think clang takes __builtin_constant_p() into account in the front end but I could be wrong. In fact, I think clang (and even gcc sometimes) will still warn for code even if it is within an 'if (0)' block, it's been used as justification before in commit 37b47298ab86 ("sched: Disable -Wunused-but-set-variable").

Hmm, well, the original warning was indeed a bug, but I think that the __builtin_constant_p() should be the fix. So clang helped in finding the bug, but is being stupid about allowing the solution (unless it thinks "some-string" is not a constant?).

I'll add the patch regardless and even keep the reported by. But I'll replace the "closes" link with just "link" as it's not technically closed.

-- Steve

#6 lore raw
Quoted 26 lines · Steven Rostedt
Quoted 15 lines · On Thu, 29 Feb 2024 21:11:31 -0700 Nathan Chancellor <[email protected]> wrote:
Quoted 13 lines
#define __assign_str(dst, src)						\
	do {								\
		char *__str__ = __get_str(dst);				\
		int __len__ = __get_dynamic_array_len(dst) - 1;		\
		if (__builtin_constant_p(src))				\
			WARN_ON_ONCE(strcmp((src), __data_offsets.dst##_ptr_)); \
		else							\
			WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);\
		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
		       EVENT_NULL_STR, __len__);			\
		__str__[__len__] = '\0';				\
	} while (0)
Quoted 1 line

Then the compiler may be better in optimizing out the "bad" portion.

Quoted 7 lines

No, that does not work either, I diffed the warnings and they are identical minus line numbers. I don't think clang takes __builtin_constant_p() into account in the front end but I could be wrong. In fact, I think clang (and even gcc sometimes) will still warn for code even if it is within an 'if (0)' block, it's been used as justification before in commit 37b47298ab86 ("sched: Disable -Wunused-but-set-variable").

Quoted 4 lines

Hmm, well, the original warning was indeed a bug, but I think that the __builtin_constant_p() should be the fix. So clang helped in finding the bug, but is being stupid about allowing the solution (unless it thinks "some-string" is not a constant?).

No, I just don't think that it makes any determination on whether src is constant or not at the point in the pipeline that this warning fires.

Quoted 2 lines

I'll add the patch regardless and even keep the reported by. But I'll replace the "closes" link with just "link" as it's not technically closed.

This diff on top of that suggestion above will hide the warning. There will be a semantic conflict against Andrew's -mm tree in -next due to bumping the minimum supported version of LLVM there but that is easy for both Stephen and Linus to handle (change '11' -> '13').

include/trace/stages/stage6_event_callback.h +6 -1
index c7789a851536..f272ab0b5cce 100644
@@ -37,8 +37,13 @@
 		int __len__ = __get_dynamic_array_len(dst) - 1;		\
 		if (__builtin_constant_p(src))				\
 			WARN_ON_ONCE(strcmp((src), __data_offsets.dst##_ptr_)); \
-		else							\
+		else {							\
+			__diag_push();					\
+			__diag_ignore(clang, 11, "-Wstring-compare",	\
+				      "Invalid for this branch");	\
 			WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);\
+			__diag_pop();					\
+		}							\
 		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
 		       EVENT_NULL_STR, __len__);			\
 		__str__[__len__] = '\0';				\

However, your suggested change appears to cause -Wincompatible-pointer-types when building that configuration fully, although it seems to be the inverse problem as above, so maybe the same __diag macros can be used to shut it up as well.

  In file included from net/core/net-traces.c:37:
  In file included from include/trace/events/qdisc.h:153:
  In file included from include/trace/define_trace.h:102:
  In file included from include/trace/trace_events.h:419:
  include/trace/events/qdisc.h:116:3: error: incompatible pointer types passing 'struct net_device *' to parameter of type 'const char *' [-Werror,-Wincompatible-pointer-types]
    102 |                 __string(       dev,            qdisc_dev(q)    )
        |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    103 |                 __string(       kind,           q->ops->id      )
        |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    104 |                 __field(        u32,            parent          )
        |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    105 |                 __field(        u32,            handle          )
        |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    106 |         ),
        |         ~~
    107 |
    108 |         TP_fast_assign(
        |         ~~~~~~~~~~~~~~~
    109 |                 __assign_str(dev, qdisc_dev(q));
        |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    110 |                 __assign_str(kind, q->ops->id);
        |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    111 |                 __entry->parent = q->parent;
        |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    112 |                 __entry->handle = q->handle;
        |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    113 |         ),
        |         ~~
    114 |
    115 |         TP_printk("dev=%s kind=%s parent=%x:%x handle=%x:%x", __get_str(dev),
        |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    116 |                   __get_str(kind), TC_H_MAJ(__entry->parent) >> 16, TC_H_MIN(__entry->parent),
        |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    117 |                   TC_H_MAJ(__entry->handle) >> 16, TC_H_MIN(__entry->handle))
        |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  include/trace/stages/stage6_event_callback.h:39:24: note: expanded from macro '__assign_str'
     39 |                         WARN_ON_ONCE(strcmp((src), __data_offsets.dst##_ptr_)); \
        |                                             ^
  include/asm-generic/bug.h:111:25: note: expanded from macro 'WARN_ON_ONCE'
    111 |         int __ret_warn_on = !!(condition);                      \
        |                                ^
  include/trace/stages/stage6_event_callback.h:142:33: note: expanded from macro 'TP_fast_assign'
    142 | #define TP_fast_assign(args...) args
        |                                 ^
  include/trace/trace_events.h:44:16: note: expanded from macro 'TRACE_EVENT'
     40 |         DECLARE_EVENT_CLASS(name,                              \
        |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     41 |                              PARAMS(proto),                    \
        |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     42 |                              PARAMS(args),                     \
        |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     43 |                              PARAMS(tstruct),                  \
        |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     44 |                              PARAMS(assign),                   \
        |                              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
     45 |                              PARAMS(print));                   \
        |                              ~~~~~~~~~~~~~~
  include/linux/tracepoint.h:107:25: note: expanded from macro 'PARAMS'
    107 | #define PARAMS(args...) args
        |                         ^
  include/trace/trace_events.h:402:4: note: expanded from macro 'DECLARE_EVENT_CLASS'
    402 |         { assign; }                                                     \
        |           ^~~~~~
  include/linux/string.h:86:31: note: passing argument to parameter here
     86 | extern int strcmp(const char *,const char *);
        |                               ^

Cheers,
Nathan

maintainer
#7 lore raw
Quoted 4 lines · On Fri, 1 Mar 2024 11:46:20 -0700 Nathan Chancellor <[email protected]> wrote:

However, your suggested change appears to cause -Wincompatible-pointer-types when building that configuration fully, although it seems to be the inverse problem as above, so maybe the same __diag macros can be used to shut it up as well.

It should not be quieted.

Quoted 7 lines

In file included from net/core/net-traces.c:37:
In file included from include/trace/events/qdisc.h:153:
In file included from include/trace/define_trace.h:102:
In file included from include/trace/trace_events.h:419:
include/trace/events/qdisc.h:116:3: error: incompatible pointer types passing 'struct net_device *' to parameter of type 'const char *' [-Werror,-Wincompatible-pointer-types]
102 | __string( dev, qdisc_dev(q) )

Yes, and that's a real bug which I also hit and reported:

https://lore.kernel.org/all/[email protected]/

And posted a patch for:

https://lore.kernel.org/all/[email protected]/

And I'll need to apply that before I can make this fix.

Thanks,

-- Steve