netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* net/sunrpc/sched.c: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead)
@ 2024-03-18  9:25 Naresh Kamboju
  2024-03-18 15:43 ` Nathan Chancellor
  0 siblings, 1 reply; 2+ messages in thread
From: Naresh Kamboju @ 2024-03-18  9:25 UTC (permalink / raw)
  To: Netdev, clang-built-linux, open list, lkft-triage
  Cc: David S. Miller, Nathan Chancellor, Trond Myklebust, Eric Dumazet

The following build warnings / errors noticed on x86 kselftests build with
clang nightly  / clang-17 on Linux  next tag next-20240318.

This build config is generated from kselftest merge configs [1].

Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>

Build log:
-----------
In file included from net/sunrpc/sched.c:31:
In file included from include/trace/events/sunrpc.h:2524:
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:707:4: error: result of comparison
against a string literal is unspecified (use an explicit string
comparison function instead) [-Werror,-Wstring-compare]
  667 |                         __assign_str(progname,
      |                         ~~~~~~~~~~~~~~~~~~~~~~
  668 |                                      task->tk_client->cl_program->name);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  669 |                         __entry->version = task->tk_client->cl_vers;
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  670 |                         __assign_str(procedure,
task->tk_msg.rpc_proc->p_name);
      |

[1] steps to reproduce:
-----------
tuxmake --runtime podman --target-arch x86_64 --toolchain
clang-nightly --kconfig
https://storage.tuxsuite.com/public/linaro/lkft/builds/2dqIWv3Qq5qYmJfnmKfkSg9fvN0/config
LLVM=1 LLVM_IAS=1 debugkernel cpupower headers kernel kselftest
modules


Links:
 - https://storage.tuxsuite.com/public/linaro/lkft/builds/2dqIWv3Qq5qYmJfnmKfkSg9fvN0/
 - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20240318/testrun/23069554/suite/build/test/clang-nightly-lkftconfig-kselftest/log
 - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20240318/testrun/23069554/suite/build/test/clang-nightly-lkftconfig-kselftest/details/


--
Linaro LKFT
https://lkft.linaro.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: net/sunrpc/sched.c: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead)
  2024-03-18  9:25 net/sunrpc/sched.c: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) Naresh Kamboju
@ 2024-03-18 15:43 ` Nathan Chancellor
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Chancellor @ 2024-03-18 15:43 UTC (permalink / raw)
  To: Naresh Kamboju
  Cc: Netdev, clang-built-linux, open list, lkft-triage,
	David S. Miller, Trond Myklebust, Eric Dumazet, rostedt,
	linux-trace-kernel

Hi Naresh,

On Mon, Mar 18, 2024 at 02:55:54PM +0530, Naresh Kamboju wrote:
> The following build warnings / errors noticed on x86 kselftests build with
> clang nightly  / clang-17 on Linux  next tag next-20240318.
> 
> This build config is generated from kselftest merge configs [1].
> 
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> 
> Build log:
> -----------
> In file included from net/sunrpc/sched.c:31:
> In file included from include/trace/events/sunrpc.h:2524:
> 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:707:4: error: result of comparison
> against a string literal is unspecified (use an explicit string
> comparison function instead) [-Werror,-Wstring-compare]
>   667 |                         __assign_str(progname,
>       |                         ~~~~~~~~~~~~~~~~~~~~~~
>   668 |                                      task->tk_client->cl_program->name);
>       |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   669 |                         __entry->version = task->tk_client->cl_vers;
>       |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   670 |                         __assign_str(procedure,
> task->tk_msg.rpc_proc->p_name);
>       |

Thanks for the report. This is caused by commit 433e1d88a3be ("tracing:
Add warning if string in __assign_str() does not match __string()") from
the tracing tree, not a change on the netdev side (although I have left
them on CC for this reply so they are aware of that).

To resolve it, [1] needs to be applied then the following diff can be
applied on top of that to fully clear it up (as __builtin_constant_p()
does not influence diagnostics in the front end, so the warning still
triggers on the else branch when it will really use strcmp(), as Steve
tested at [2]).

[1]: https://lore.kernel.org/20240312113002.00031668@gandalf.local.home/
[2]: https://lore.kernel.org/20240313161420.3b668558@gandalf.local.home/

diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h
index 83da83a0c14f..dbd27adb1b83 100644
--- a/include/trace/stages/stage6_event_callback.h
+++ b/include/trace/stages/stage6_event_callback.h
@@ -35,9 +35,14 @@
 	do {								\
 		char *__str__ = __get_str(dst);				\
 		int __len__ = __get_dynamic_array_len(dst) - 1;		\
+		__diag_push();						\
+		__diag_ignore(clang, 13, "-Wstring-compare",		\
+			      "__builtin_constant_p() ensures strcmp()"	\
+			      "will be used for string literals");	\
 		WARN_ON_ONCE(__builtin_constant_p(src) ?		\
 			     strcmp((src), __data_offsets.dst##_ptr_) :	\
 			     (src) != __data_offsets.dst##_ptr_);	\
+		__diag_pop();						\
 		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
 		       EVENT_NULL_STR, __len__);			\
 		__str__[__len__] = '\0';				\

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-18 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18  9:25 net/sunrpc/sched.c: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) Naresh Kamboju
2024-03-18 15:43 ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).