From 50eef6566b223eb2a6c027e9a862bc279bd06ed7 Mon Sep 17 00:00:00 2001 From: Elyes Haouas Date: Wed, 13 Jul 2022 18:07:58 +0200 Subject: lint/checkpatch: Add check for used comma where semicolon could be This reduce the difference with linux v5.19-rc7. Signed-off-by: Elyes Haouas Change-Id: I6d3a49378008bad61b2a18bd8cb28be952a18006 Reviewed-on: https://review.coreboot.org/c/coreboot/+/65837 Tested-by: build bot (Jenkins) Reviewed-by: Martin L Roth --- util/lint/checkpatch.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/util/lint/checkpatch.pl b/util/lint/checkpatch.pl index 2fc3c14dec..650ddffd98 100755 --- a/util/lint/checkpatch.pl +++ b/util/lint/checkpatch.pl @@ -5055,6 +5055,17 @@ sub process { } } +# check if a statement with a comma should be two statements like: +# foo = bar(), /* comma should be semicolon */ +# bar = baz(); + if (defined($stat) && + $stat =~ /^\+\s*(?:$Lval\s*$Assignment\s*)?$FuncArg\s*,\s*(?:$Lval\s*$Assignment\s*)?$FuncArg\s*;\s*$/) { + my $cnt = statement_rawlines($stat); + my $herectx = get_stat_here($linenr, $cnt, $here); + WARN("SUSPECT_COMMA_SEMICOLON", + "Possible comma where semicolon could be used\n" . $herectx); + } + # return is not a function if (defined($stat) && $stat =~ /^.\s*return(\s*)\(/s) { my $spacing = $1; -- cgit v1.2.3