Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] trace-cmd: Silence a logical-not-parentheses warning
@ 2021-04-28  5:25 Ian Rogers
  2021-04-28 13:20 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2021-04-28  5:25 UTC (permalink / raw)
  To: linux-trace-devel, Tzvetomir Stoyanov, Steven Rostedt; +Cc: Ian Rogers

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.

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);
-- 
2.31.1.527.g47e6f16901-goog


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

* Re: [PATCH] trace-cmd: Silence a logical-not-parentheses warning
  2021-04-28  5:25 [PATCH] trace-cmd: Silence a logical-not-parentheses warning Ian Rogers
@ 2021-04-28 13:20 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2021-04-28 13:20 UTC (permalink / raw)
  To: Ian Rogers; +Cc: linux-trace-devel, Tzvetomir Stoyanov

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);


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28  5:25 [PATCH] trace-cmd: Silence a logical-not-parentheses warning Ian Rogers
2021-04-28 13:20 ` Steven Rostedt

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git