From e235a0de181d3b30ce7c3653350cd7d24ff1ea03 Mon Sep 17 00:00:00 2001 From: Elyes Haouas Date: Wed, 13 Jul 2022 16:52:48 +0200 Subject: [PATCH] lint/checkpatch: Update 'uncoalesced string fragments' This reduce the difference with linux v5.19-rc7. Signed-off-by: Elyes Haouas Change-Id: I21b2a0d87cbf610fc48e273ed78ab779ad4a6932 Reviewed-on: https://review.coreboot.org/c/coreboot/+/65832 Tested-by: build bot (Jenkins) Reviewed-by: Martin L Roth --- util/lint/checkpatch.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/util/lint/checkpatch.pl b/util/lint/checkpatch.pl index 72c0f365d9..2bc74eb65c 100755 --- a/util/lint/checkpatch.pl +++ b/util/lint/checkpatch.pl @@ -5720,9 +5720,15 @@ sub process { } # uncoalesced string fragments - if ($line =~ /$String\s*"/) { - WARN("STRING_FRAGMENTS", - "Consecutive strings are generally better as a single string\n" . $herecurr); + if ($line =~ /$String\s*[Lu]?"/) { + if (WARN("STRING_FRAGMENTS", + "Consecutive strings are generally better as a single string\n" . $herecurr) && + $fix) { + while ($line =~ /($String)(?=\s*")/g) { + my $extracted_string = substr($rawline, $-[0], $+[0] - $-[0]); + $fixed[$fixlinenr] =~ s/\Q$extracted_string\E\s*"/substr($extracted_string, 0, -1)/e; + } + } } # check for non-standard and hex prefixed decimal printf formats