* [PATCH] perf intel-bts: Use true,false for bool variable @ 2020-11-06 6:29 xiakaixu1987 2020-11-09 11:39 ` Peter Zijlstra 0 siblings, 1 reply; 3+ messages in thread From: xiakaixu1987 @ 2020-11-06 6:29 UTC (permalink / raw) To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung, adrian.hunter Cc: linux-kernel, Kaixu Xia From: Kaixu Xia <kaixuxia@tencent.com> Fix the following coccinelle reports: ./tools/perf/util/intel-bts.c:472:3-13: WARNING: Assignment of 0/1 to bool variable ./tools/perf/util/intel-bts.c:515:3-13: WARNING: Assignment of 0/1 to bool variable Reported-by: Tosk Robot <tencent_os_robot@tencent.com> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com> --- tools/perf/util/intel-bts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index af1e78d76228..aa4fad92c79b 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -469,7 +469,7 @@ static int intel_bts_process_queue(struct intel_bts_queue *btsq, u64 *timestamp) if (!buffer) { if (!btsq->bts->sampling_mode) - btsq->done = 1; + btsq->done = true; err = 1; goto out_put; } @@ -512,7 +512,7 @@ static int intel_bts_process_queue(struct intel_bts_queue *btsq, u64 *timestamp) *timestamp = btsq->buffer->reference; } else { if (!btsq->bts->sampling_mode) - btsq->done = 1; + btsq->done = true; } out_put: thread__put(thread); -- 2.20.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf intel-bts: Use true,false for bool variable 2020-11-06 6:29 [PATCH] perf intel-bts: Use true,false for bool variable xiakaixu1987 @ 2020-11-09 11:39 ` Peter Zijlstra 2020-11-09 16:22 ` Julia Lawall 0 siblings, 1 reply; 3+ messages in thread From: Peter Zijlstra @ 2020-11-09 11:39 UTC (permalink / raw) To: xiakaixu1987 Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung, adrian.hunter, linux-kernel, Kaixu Xia, Julia.Lawall On Fri, Nov 06, 2020 at 02:29:06PM +0800, xiakaixu1987@gmail.com wrote: > From: Kaixu Xia <kaixuxia@tencent.com> > > Fix the following coccinelle reports: > > ./tools/perf/util/intel-bts.c:472:3-13: WARNING: Assignment of 0/1 to bool variable > ./tools/perf/util/intel-bts.c:515:3-13: WARNING: Assignment of 0/1 to bool variable > > Reported-by: Tosk Robot <tencent_os_robot@tencent.com> > Signed-off-by: Kaixu Xia <kaixuxia@tencent.com> Here, I've fixed it differently. --- Subject: coccinelle: Remove broken check From: Peter Zijlstra <peterz@infradead.org> Date: Mon Nov 9 12:32:00 CET 2020 Get rid of the endless stream of patches that complain about: "WARNING: Assignment of 0/1 to bool variable" Which is perfectly valid C. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> --- scripts/coccinelle/misc/boolinit.cocci | 195 --------------------------------- 1 file changed, 195 deletions(-) --- a/scripts/coccinelle/misc/boolinit.cocci +++ /dev/null @@ -1,195 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/// Bool initializations should use true and false. Bool tests don't need -/// comparisons. Based on contributions from Joe Perches, Rusty Russell -/// and Bruce W Allan. -/// -// Confidence: High -// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. -// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. -// URL: http://coccinelle.lip6.fr/ -// Options: --include-headers - -virtual patch -virtual context -virtual org -virtual report - -@boolok@ -symbol true,false; -@@ -( -true -| -false -) - -@depends on patch@ -bool t; -@@ - -( -- t == true -+ t -| -- true == t -+ t -| -- t != true -+ !t -| -- true != t -+ !t -| -- t == false -+ !t -| -- false == t -+ !t -| -- t != false -+ t -| -- false != t -+ t -) - -@depends on patch disable is_zero, isnt_zero@ -bool t; -@@ - -( -- t == 1 -+ t -| -- t != 1 -+ !t -| -- t == 0 -+ !t -| -- t != 0 -+ t -) - -@depends on patch && boolok@ -bool b; -@@ -( - b = -- 0 -+ false -| - b = -- 1 -+ true -) - -// --------------------------------------------------------------------- - -@r1 depends on !patch@ -bool t; -position p; -@@ - -( -* t@p == true -| -* true == t@p -| -* t@p != true -| -* true != t@p -| -* t@p == false -| -* false == t@p -| -* t@p != false -| -* false != t@p -) - -@r2 depends on !patch disable is_zero, isnt_zero@ -bool t; -position p; -@@ - -( -* t@p == 1 -| -* t@p != 1 -| -* t@p == 0 -| -* t@p != 0 -) - -@r3 depends on !patch && boolok@ -bool b; -position p1; -@@ -( -*b@p1 = 0 -| -*b@p1 = 1 -) - -@r4 depends on !patch@ -bool b; -position p2; -identifier i; -constant c != {0,1}; -@@ -( - b = i -| -*b@p2 = c -) - -@script:python depends on org@ -p << r1.p; -@@ - -cocci.print_main("WARNING: Comparison to bool",p) - -@script:python depends on org@ -p << r2.p; -@@ - -cocci.print_main("WARNING: Comparison of 0/1 to bool variable",p) - -@script:python depends on org@ -p1 << r3.p1; -@@ - -cocci.print_main("WARNING: Assignment of 0/1 to bool variable",p1) - -@script:python depends on org@ -p2 << r4.p2; -@@ - -cocci.print_main("ERROR: Assignment of non-0/1 constant to bool variable",p2) - -@script:python depends on report@ -p << r1.p; -@@ - -coccilib.report.print_report(p[0],"WARNING: Comparison to bool") - -@script:python depends on report@ -p << r2.p; -@@ - -coccilib.report.print_report(p[0],"WARNING: Comparison of 0/1 to bool variable") - -@script:python depends on report@ -p1 << r3.p1; -@@ - -coccilib.report.print_report(p1[0],"WARNING: Assignment of 0/1 to bool variable") - -@script:python depends on report@ -p2 << r4.p2; -@@ - -coccilib.report.print_report(p2[0],"ERROR: Assignment of non-0/1 constant to bool variable") ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf intel-bts: Use true,false for bool variable 2020-11-09 11:39 ` Peter Zijlstra @ 2020-11-09 16:22 ` Julia Lawall 0 siblings, 0 replies; 3+ messages in thread From: Julia Lawall @ 2020-11-09 16:22 UTC (permalink / raw) To: Peter Zijlstra Cc: xiakaixu1987, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung, adrian.hunter, linux-kernel, Kaixu Xia On Mon, 9 Nov 2020, Peter Zijlstra wrote: > On Fri, Nov 06, 2020 at 02:29:06PM +0800, xiakaixu1987@gmail.com wrote: > > From: Kaixu Xia <kaixuxia@tencent.com> > > > > Fix the following coccinelle reports: > > > > ./tools/perf/util/intel-bts.c:472:3-13: WARNING: Assignment of 0/1 to bool variable > > ./tools/perf/util/intel-bts.c:515:3-13: WARNING: Assignment of 0/1 to bool variable > > > > Reported-by: Tosk Robot <tencent_os_robot@tencent.com> > > Signed-off-by: Kaixu Xia <kaixuxia@tencent.com> > > Here, I've fixed it differently. I applied this version, but removed the above text from the log message. julia > > --- > Subject: coccinelle: Remove broken check > From: Peter Zijlstra <peterz@infradead.org> > Date: Mon Nov 9 12:32:00 CET 2020 > > Get rid of the endless stream of patches that complain about: > > "WARNING: Assignment of 0/1 to bool variable" > > Which is perfectly valid C. > > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> > --- > scripts/coccinelle/misc/boolinit.cocci | 195 --------------------------------- > 1 file changed, 195 deletions(-) > > --- a/scripts/coccinelle/misc/boolinit.cocci > +++ /dev/null > @@ -1,195 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0-only > -/// Bool initializations should use true and false. Bool tests don't need > -/// comparisons. Based on contributions from Joe Perches, Rusty Russell > -/// and Bruce W Allan. > -/// > -// Confidence: High > -// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. > -// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. > -// URL: http://coccinelle.lip6.fr/ > -// Options: --include-headers > - > -virtual patch > -virtual context > -virtual org > -virtual report > - > -@boolok@ > -symbol true,false; > -@@ > -( > -true > -| > -false > -) > - > -@depends on patch@ > -bool t; > -@@ > - > -( > -- t == true > -+ t > -| > -- true == t > -+ t > -| > -- t != true > -+ !t > -| > -- true != t > -+ !t > -| > -- t == false > -+ !t > -| > -- false == t > -+ !t > -| > -- t != false > -+ t > -| > -- false != t > -+ t > -) > - > -@depends on patch disable is_zero, isnt_zero@ > -bool t; > -@@ > - > -( > -- t == 1 > -+ t > -| > -- t != 1 > -+ !t > -| > -- t == 0 > -+ !t > -| > -- t != 0 > -+ t > -) > - > -@depends on patch && boolok@ > -bool b; > -@@ > -( > - b = > -- 0 > -+ false > -| > - b = > -- 1 > -+ true > -) > - > -// --------------------------------------------------------------------- > - > -@r1 depends on !patch@ > -bool t; > -position p; > -@@ > - > -( > -* t@p == true > -| > -* true == t@p > -| > -* t@p != true > -| > -* true != t@p > -| > -* t@p == false > -| > -* false == t@p > -| > -* t@p != false > -| > -* false != t@p > -) > - > -@r2 depends on !patch disable is_zero, isnt_zero@ > -bool t; > -position p; > -@@ > - > -( > -* t@p == 1 > -| > -* t@p != 1 > -| > -* t@p == 0 > -| > -* t@p != 0 > -) > - > -@r3 depends on !patch && boolok@ > -bool b; > -position p1; > -@@ > -( > -*b@p1 = 0 > -| > -*b@p1 = 1 > -) > - > -@r4 depends on !patch@ > -bool b; > -position p2; > -identifier i; > -constant c != {0,1}; > -@@ > -( > - b = i > -| > -*b@p2 = c > -) > - > -@script:python depends on org@ > -p << r1.p; > -@@ > - > -cocci.print_main("WARNING: Comparison to bool",p) > - > -@script:python depends on org@ > -p << r2.p; > -@@ > - > -cocci.print_main("WARNING: Comparison of 0/1 to bool variable",p) > - > -@script:python depends on org@ > -p1 << r3.p1; > -@@ > - > -cocci.print_main("WARNING: Assignment of 0/1 to bool variable",p1) > - > -@script:python depends on org@ > -p2 << r4.p2; > -@@ > - > -cocci.print_main("ERROR: Assignment of non-0/1 constant to bool variable",p2) > - > -@script:python depends on report@ > -p << r1.p; > -@@ > - > -coccilib.report.print_report(p[0],"WARNING: Comparison to bool") > - > -@script:python depends on report@ > -p << r2.p; > -@@ > - > -coccilib.report.print_report(p[0],"WARNING: Comparison of 0/1 to bool variable") > - > -@script:python depends on report@ > -p1 << r3.p1; > -@@ > - > -coccilib.report.print_report(p1[0],"WARNING: Assignment of 0/1 to bool variable") > - > -@script:python depends on report@ > -p2 << r4.p2; > -@@ > - > -coccilib.report.print_report(p2[0],"ERROR: Assignment of non-0/1 constant to bool variable") > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-09 16:22 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-11-06 6:29 [PATCH] perf intel-bts: Use true,false for bool variable xiakaixu1987 2020-11-09 11:39 ` Peter Zijlstra 2020-11-09 16:22 ` Julia Lawall
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).