From: Steven Rostedt <rostedt@goodmis.org>
To: Ian Rogers <irogers@google.com>
Cc: linux-trace-devel@vger.kernel.org,
Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
Subject: Re: [PATCH] trace-cmd: Silence a logical-not-parentheses warning
Date: Wed, 28 Apr 2021 09:20:03 -0400 [thread overview]
Message-ID: <20210428092003.14555460@gandalf.local.home> (raw)
In-Reply-To: <20210428052540.3364743-1-irogers@google.com>
On Tue, 27 Apr 2021 22:25:40 -0700
Ian Rogers <irogers@google.com> wrote:
> Clang 12 generates a warning of:
> ./tracecmd/trace-stat.c:719:15: error: logical not is only applied to the left hand side of this comparison [-Werror,-Wlogical-not-parentheses]
> if (clock && !strcmp(clock, "local") == 0)
> ^ ~~
> ./tracecmd/trace-stat.c:719:15: note: add parentheses after the '!' to evaluate the comparison first
> if (clock && !strcmp(clock, "local") == 0)
> ^
> ( )
> ./tracecmd/trace-stat.c:719:15: note: add parentheses around left hand side expression to silence this warning
> if (clock && !strcmp(clock, "local") == 0)
> ^
> ( )
>
> Silence by using "!= 0" as done elsewhere in the code.
Thanks, this does look like a nice clean up, and not just a removal of a
warning on Clang.
-- Steve
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tracecmd/trace-stat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c
> index 3112787..cb92622 100644
> --- a/tracecmd/trace-stat.c
> +++ b/tracecmd/trace-stat.c
> @@ -716,7 +716,7 @@ static void report_clock(struct buffer_instance *instance)
> clock = tracefs_get_clock(tracefs);
>
> /* Default clock is "local", only show others */
> - if (clock && !strcmp(clock, "local") == 0)
> + if (clock && strcmp(clock, "local") != 0)
> printf("\nClock: %s\n", clock);
>
> free(clock);
prev parent reply other threads:[~2021-04-28 13:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 5:25 [PATCH] trace-cmd: Silence a logical-not-parentheses warning Ian Rogers
2021-04-28 13:20 ` Steven Rostedt [this message]
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=20210428092003.14555460@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=irogers@google.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=tz.stoyanov@gmail.com \
/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 NNTP newsgroup(s).