scripts/checkpatch.pl: Ignore TST_* in constant checks
PATCH 1/1 scripts/checkpatch.pl: Ignore TST_* in constant checks
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 <[email protected]>
Signed-off-by Cyril Hrubis <[email protected]>
--- scripts/checkpatch.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +3 -1
@@ -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) &&
Signature · 5 lines
2.32.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/1 scripts/checkpatch.pl: Ignore TST_* in constant checks
Hi Cyril,
Reviewed-by Petr Vorel <[email protected]>
Tested-by Petr Vorel <[email protected]>
Thanks!
Kind regards,
Petr
PATCH 1/1 scripts/checkpatch.pl: Ignore TST_* in constant checks
Hi!
Pushed.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp