diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/lint/checkpatch.pl | 12 |
1 files 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 |