All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: kernel test robot <lkp@intel.com>,
	llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	"Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Subject: Re: [trace:trace/for-next 28/29] include/trace/events/sunrpc.h:703:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead)
Date: Thu, 29 Feb 2024 21:11:31 -0700	[thread overview]
Message-ID: <20240301041131.GB577965@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20240229185558.70b6ea86@gandalf.local.home>

On Thu, Feb 29, 2024 at 06:55:58PM -0500, Steven Rostedt wrote:
> On Thu, 29 Feb 2024 16:44:55 -0700
> Nathan Chancellor <nathan@kernel.org> wrote:
> 
> > > 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.

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

  reply	other threads:[~2024-03-01  4:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 13:35 [trace:trace/for-next 28/29] include/trace/events/sunrpc.h:703:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) kernel test robot
2024-02-29 23:06 ` Steven Rostedt
2024-02-29 23:44   ` Nathan Chancellor
2024-02-29 23:55     ` Steven Rostedt
2024-03-01  4:11       ` Nathan Chancellor [this message]
2024-03-01 15:47         ` Steven Rostedt
2024-03-01 18:46           ` Nathan Chancellor
2024-03-01 18:59             ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240301041131.GB577965@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=mhiramat@kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.