patches.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Justin Stitt <justinstitt@google.com>
Cc: Nathan Chancellor <nathan@kernel.org>,
	mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
	ndesaulniers@google.com, morbo@google.com,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	llvm@lists.linux.dev, patches@lists.linux.dev,
	Linux Kernel Functional Testing <lkft@linaro.org>
Subject: Re: [PATCH 2/2] tracing: Ignore -Wstring-compare with diagnostic macros
Date: Tue, 19 Mar 2024 20:37:16 -0400	[thread overview]
Message-ID: <20240319203716.208c9b29@gandalf.local.home> (raw)
In-Reply-To: <CAFhGd8q_4QfjPwGhtfOA40ZGNF7_wf3V43rAvcb_qXQnz1TFOw@mail.gmail.com>

On Tue, 19 Mar 2024 17:30:41 -0700
Justin Stitt <justinstitt@google.com> wrote:


> > diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h
> > index 83da83a0c14f..56a4eea5a48e 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, 11, "-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_);       \  
> 
> What exactly is the point of the literal string comparison? Why
> doesn't strcmp do the trick?

This is done in the hotpath, and is only for debugging. The string passed
into __string() should be the same as the string passed into __assign_str().

But this is moot as I ended up always using strcmp() even if it will slow
down the recording of the event.

Next merge window the src parameter (along with the strcmp() checks) are
going away.

-- Steve


> 
> > +               __diag_pop();                                           \
> >                 memcpy(__str__, __data_offsets.dst##_ptr_ ? :           \
> >                        EVENT_NULL_STR, __len__);                        \
> >                 __str__[__len__] = '\0';                                \
> >
> > --
> > 2.44.0
> >  


  reply	other threads:[~2024-03-20  0:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19 16:07 [PATCH 0/2] tracing: Fully silence instance of -Wstring-compare Nathan Chancellor
2024-03-19 16:07 ` [PATCH 1/2] compiler_types: Ensure __diag_clang() is always available Nathan Chancellor
2024-03-20  0:35   ` Justin Stitt
2024-03-19 16:07 ` [PATCH 2/2] tracing: Ignore -Wstring-compare with diagnostic macros Nathan Chancellor
2024-03-20  0:30   ` Justin Stitt
2024-03-20  0:37     ` Steven Rostedt [this message]
2024-03-19 22:15 ` [PATCH 0/2] tracing: Fully silence instance of -Wstring-compare Steven Rostedt
2024-03-19 22:27   ` Nathan Chancellor

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=20240319203716.208c9b29@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lkft@linaro.org \
    --cc=llvm@lists.linux.dev \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=patches@lists.linux.dev \
    /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 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 read-only IMAP folder(s) and NNTP newsgroup(s).