diff options
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 5cb7cfd08ce2..f2e00dc0ae89 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -5330,15 +5330,28 @@ sub process { | |||
| 5330 | } | 5330 | } |
| 5331 | 5331 | ||
| 5332 | # concatenated string without spaces between elements | 5332 | # concatenated string without spaces between elements |
| 5333 | if ($line =~ /$String[A-Z_]/ || $line =~ /[A-Za-z0-9_]$String/) { | 5333 | if ($line =~ /$String[A-Za-z0-9_]/ || $line =~ /[A-Za-z0-9_]$String/) { |
| 5334 | CHK("CONCATENATED_STRING", | 5334 | if (CHK("CONCATENATED_STRING", |
| 5335 | "Concatenated strings should use spaces between elements\n" . $herecurr); | 5335 | "Concatenated strings should use spaces between elements\n" . $herecurr) && |
| 5336 | $fix) { | ||
| 5337 | while ($line =~ /($String)/g) { | ||
| 5338 | my $extracted_string = substr($rawline, $-[0], $+[0] - $-[0]); | ||
| 5339 | $fixed[$fixlinenr] =~ s/\Q$extracted_string\E([A-Za-z0-9_])/$extracted_string $1/; | ||
| 5340 | $fixed[$fixlinenr] =~ s/([A-Za-z0-9_])\Q$extracted_string\E/$1 $extracted_string/; | ||
| 5341 | } | ||
| 5342 | } | ||
| 5336 | } | 5343 | } |
| 5337 | 5344 | ||
| 5338 | # uncoalesced string fragments | 5345 | # uncoalesced string fragments |
| 5339 | if ($line =~ /$String\s*"/) { | 5346 | if ($line =~ /$String\s*"/) { |
| 5340 | WARN("STRING_FRAGMENTS", | 5347 | if (WARN("STRING_FRAGMENTS", |
| 5341 | "Consecutive strings are generally better as a single string\n" . $herecurr); | 5348 | "Consecutive strings are generally better as a single string\n" . $herecurr) && |
| 5349 | $fix) { | ||
| 5350 | while ($line =~ /($String)(?=\s*")/g) { | ||
| 5351 | my $extracted_string = substr($rawline, $-[0], $+[0] - $-[0]); | ||
| 5352 | $fixed[$fixlinenr] =~ s/\Q$extracted_string\E\s*"/substr($extracted_string, 0, -1)/e; | ||
| 5353 | } | ||
| 5354 | } | ||
| 5342 | } | 5355 | } |
| 5343 | 5356 | ||
| 5344 | # check for non-standard and hex prefixed decimal printf formats | 5357 | # check for non-standard and hex prefixed decimal printf formats |
