From d92fcf448f3e50f605b2c4eda13772680f47516f Mon Sep 17 00:00:00 2001 From: Elyes Haouas Date: Wed, 13 Jul 2022 16:34:29 +0200 Subject: [PATCH] lint/checkpatch: Update 'check for logical continuations' This reduce the difference with linux v5.19-rc7. Signed-off-by: Elyes Haouas Change-Id: I222e3378ded4cd73d0141cd1e38ac3282d311cc4 Reviewed-on: https://review.coreboot.org/c/coreboot/+/65827 Tested-by: build bot (Jenkins) Reviewed-by: Martin L Roth --- util/lint/checkpatch.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/util/lint/checkpatch.pl b/util/lint/checkpatch.pl index a8ecff4e71..f41f6ab244 100755 --- a/util/lint/checkpatch.pl +++ b/util/lint/checkpatch.pl @@ -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