History

checkpatch: use $String consistently

String detection where a source line with a string constant is converted can either have an X or a space. Some of the string detection regexes do not allow the space character, but there is a handy $String variable that does. Convert the remaining uses of string detection regexes to use the $String variable to reduce possible false negatives.

Joe Perches committed 11 years ago

Commit 33acb541 parent 485ff231 file · +6 −6Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+6−6
@@ -1008,7 +1008,7 @@ sub sanitise_line { · 1007 unmodified lines
10081008 sub get_quoted_string {
10091009 my ($line, $rawline) = @_;
10101010
1011− return "" if ($line !~ m/(\"[X\t]+\")/g);
1011+ return "" if ($line !~ m/($String)/g);
10121012 return substr($rawline, $-[0], $+[0] - $-[0]);
10131013 }
10141014
@@ -4343,8 +4343,8 @@ sub process { · 3328 unmodified lines
43434343 }
43444344
43454345 # Flatten any obvious string concatentation.
4346− while ($dstat =~ s/("X*")\s*$Ident/$1/ ||
4347− $dstat =~ s/$Ident\s*("X*")/$1/)
4346+ while ($dstat =~ s/($String)\s*$Ident/$1/ ||
4347+ $dstat =~ s/$Ident\s*($String)/$1/)
43484348 {
43494349 }
43504350
@@ -4625,7 +4625,7 @@ sub process { · 274 unmodified lines
46254625 # to grep for the string. Make exceptions when the previous string ends in a
46264626 # newline (multiple lines in one string constant) or '\t', '\r', ';', or '{'
46274627 # (common in inline assembly) or is a octal \123 or hexadecimal \xaf value
4628− if ($line =~ /^\+\s*"[X\t]*"/ &&
4628+ if ($line =~ /^\+\s*$String/ &&
46294629 $prevline =~ /"\s*$/ &&
46304630 $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
46314631 if (WARN("SPLIT_STRING",
@@ -4671,13 +4671,13 @@ sub process { · 39 unmodified lines
46714671 }
46724672
46734673 # concatenated string without spaces between elements
4674− if ($line =~ /"X+"[A-Z_]+/ || $line =~ /[A-Z_]+"X+"/) {
4674+ if ($line =~ /$String[A-Z_]/ || $line =~ /[A-Za-z0-9_]$String/) {
46754675 CHK("CONCATENATED_STRING",
46764676 "Concatenated strings should use spaces between elements\n" . $herecurr);
46774677 }
46784678
46794679 # uncoalesced string fragments
4680− if ($line =~ /"X*"\s*"/) {
4680+ if ($line =~ /$String\s*"/) {
46814681 WARN("STRING_FRAGMENTS",
46824682 "Consecutive strings are generally better as a single string\n" . $herecurr);
46834683 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t