All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] scripts/checkpatch.pl: Ignore TST_* in constant checks
@ 2021-09-14 10:01 ` Cyril Hrubis
  2021-09-14 12:44     ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2021-09-14 10:01 UTC (permalink / raw)
  To: ltp

The checkpatch.pl thinks that TST_RET etc are constants because it
treats everything that is uppercase as a constant and hence complains at
following code:

	if (TST_RET != tc->exp_errno)
		tst_res(TFAIL, "...");

In this case both sides of the comparsion are variables and the code
is as it should be.

So this commit disables the check for 'yoda comparsion' for constants if
the identifier on the left starts with TST_.

Reported-by: Martin Doucha <mdoucha@suse.cz>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 scripts/checkpatch.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 88cb294dc..87572b2f4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5462,7 +5462,9 @@ sub process {
 			my $comp = $3;
 			my $to = $4;
 			my $newcomp = $comp;
-			if ($lead !~ /(?:$Operators|\.)\s*$/ &&
+
+			if ($const !~ /^\QTST_/ &&
+			    $lead !~ /(?:$Operators|\.)\s*$/ &&
 			    $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ &&
 			    WARN("CONSTANT_COMPARISON",
 				 "Comparisons should place the constant on the right side of the test\n" . $herecurr) &&
-- 
2.32.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH] scripts/checkpatch.pl: Ignore TST_* in constant checks
@ 2021-09-14 12:44     ` Petr Vorel
  2021-09-14 13:16         ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2021-09-14 12:44 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Tested-by: Petr Vorel <pvorel@suse.cz>

Thanks!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH] scripts/checkpatch.pl: Ignore TST_* in constant checks
@ 2021-09-14 13:16         ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2021-09-14 13:16 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
Pushed.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2021-09-14 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 10:01 [LTP] [PATCH] scripts/checkpatch.pl: Ignore TST_* in constant checks Cyril Hrubis
2021-09-14 10:01 ` Cyril Hrubis
2021-09-14 12:44   ` Petr Vorel
2021-09-14 12:44     ` Petr Vorel
2021-09-14 13:16       ` Cyril Hrubis
2021-09-14 13:16         ` Cyril Hrubis

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.