aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-06-25 18:02:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-25 20:00:41 -0400
commit33acb54a4379ccd3494580bdc30af1aa13ee4aab (patch)
treedfa43d3074a110d45ef813baf70f87d4a5b4a72e /scripts/checkpatch.pl
parent485ff23ed2575e9d479f45227749cbbcd5df3e19 (diff)
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. Signed-off-by: Joe Perches <joe@perches.com> Cc: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl12
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e46414dce05f..62669700d629 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1008,7 +1008,7 @@ sub sanitise_line {
1008sub get_quoted_string { 1008sub get_quoted_string {
1009 my ($line, $rawline) = @_; 1009 my ($line, $rawline) = @_;
1010 1010
1011 return "" if ($line !~ m/(\"[X\t]+\")/g); 1011 return "" if ($line !~ m/($String)/g);
1012 return substr($rawline, $-[0], $+[0] - $-[0]); 1012 return substr($rawline, $-[0], $+[0] - $-[0]);
1013} 1013}
1014 1014
@@ -4343,8 +4343,8 @@ sub process {
4343 } 4343 }
4344 4344
4345 # Flatten any obvious string concatentation. 4345 # Flatten any obvious string concatentation.
4346 while ($dstat =~ s/("X*")\s*$Ident/$1/ || 4346 while ($dstat =~ s/($String)\s*$Ident/$1/ ||
4347 $dstat =~ s/$Ident\s*("X*")/$1/) 4347 $dstat =~ s/$Ident\s*($String)/$1/)
4348 { 4348 {
4349 } 4349 }
4350 4350
@@ -4625,7 +4625,7 @@ sub process {
4625# to grep for the string. Make exceptions when the previous string ends in a 4625# to grep for the string. Make exceptions when the previous string ends in a
4626# newline (multiple lines in one string constant) or '\t', '\r', ';', or '{' 4626# newline (multiple lines in one string constant) or '\t', '\r', ';', or '{'
4627# (common in inline assembly) or is a octal \123 or hexadecimal \xaf value 4627# (common in inline assembly) or is a octal \123 or hexadecimal \xaf value
4628 if ($line =~ /^\+\s*"[X\t]*"/ && 4628 if ($line =~ /^\+\s*$String/ &&
4629 $prevline =~ /"\s*$/ && 4629 $prevline =~ /"\s*$/ &&
4630 $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) { 4630 $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
4631 if (WARN("SPLIT_STRING", 4631 if (WARN("SPLIT_STRING",
@@ -4671,13 +4671,13 @@ sub process {
4671 } 4671 }
4672 4672
4673# concatenated string without spaces between elements 4673# 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/) {
4675 CHK("CONCATENATED_STRING", 4675 CHK("CONCATENATED_STRING",
4676 "Concatenated strings should use spaces between elements\n" . $herecurr); 4676 "Concatenated strings should use spaces between elements\n" . $herecurr);
4677 } 4677 }
4678 4678
4679# uncoalesced string fragments 4679# uncoalesced string fragments
4680 if ($line =~ /"X*"\s*"/) { 4680 if ($line =~ /$String\s*"/) {
4681 WARN("STRING_FRAGMENTS", 4681 WARN("STRING_FRAGMENTS",
4682 "Consecutive strings are generally better as a single string\n" . $herecurr); 4682 "Consecutive strings are generally better as a single string\n" . $herecurr);
4683 } 4683 }