lint/checkpatch: Update 'check for logical continuations'

This reduce the difference with linux v5.19-rc7.

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Change-Id: I222e3378ded4cd73d0141cd1e38ac3282d311cc4
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65827
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@tutanota.com>
This commit is contained in:
Elyes Haouas 2022-07-13 16:34:29 +02:00 committed by Martin L Roth
parent 86e4a3ae05
commit d92fcf448f
1 changed files with 10 additions and 2 deletions

View File

@ -3379,8 +3379,16 @@ sub process {
# check for && or || at the start of a line
if ($rawline =~ /^\+\s*(&&|\|\|)/) {
CHK("LOGICAL_CONTINUATIONS",
"Logical continuations should be on the previous line\n" . $hereprev);
my $operator = $1;
if (CHK("LOGICAL_CONTINUATIONS",
"Logical continuations should be on the previous line\n" . $hereprev) &&
$fix && $prevrawline =~ /^\+/) {
# insert logical operator at last non-comment, non-whitepsace char on previous line
$prevline =~ /[\s$;]*$/;
my $line_end = substr($prevrawline, $-[0]);
$fixed[$fixlinenr - 1] =~ s/\Q$line_end\E$/ $operator$line_end/;
$fixed[$fixlinenr] =~ s/\Q$operator\E\s*//;
}
}
# check indentation starts on a tab stop