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>
This commit is contained in:
parent
485ff23ed2
commit
33acb54a43
|
@ -1008,7 +1008,7 @@ sub sanitise_line {
|
||||||
sub get_quoted_string {
|
sub get_quoted_string {
|
||||||
my ($line, $rawline) = @_;
|
my ($line, $rawline) = @_;
|
||||||
|
|
||||||
return "" if ($line !~ m/(\"[X\t]+\")/g);
|
return "" if ($line !~ m/($String)/g);
|
||||||
return substr($rawline, $-[0], $+[0] - $-[0]);
|
return substr($rawline, $-[0], $+[0] - $-[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4343,8 +4343,8 @@ sub process {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Flatten any obvious string concatentation.
|
# Flatten any obvious string concatentation.
|
||||||
while ($dstat =~ s/("X*")\s*$Ident/$1/ ||
|
while ($dstat =~ s/($String)\s*$Ident/$1/ ||
|
||||||
$dstat =~ s/$Ident\s*("X*")/$1/)
|
$dstat =~ s/$Ident\s*($String)/$1/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4625,7 +4625,7 @@ sub process {
|
||||||
# to grep for the string. Make exceptions when the previous string ends in a
|
# to grep for the string. Make exceptions when the previous string ends in a
|
||||||
# newline (multiple lines in one string constant) or '\t', '\r', ';', or '{'
|
# newline (multiple lines in one string constant) or '\t', '\r', ';', or '{'
|
||||||
# (common in inline assembly) or is a octal \123 or hexadecimal \xaf value
|
# (common in inline assembly) or is a octal \123 or hexadecimal \xaf value
|
||||||
if ($line =~ /^\+\s*"[X\t]*"/ &&
|
if ($line =~ /^\+\s*$String/ &&
|
||||||
$prevline =~ /"\s*$/ &&
|
$prevline =~ /"\s*$/ &&
|
||||||
$prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
|
$prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
|
||||||
if (WARN("SPLIT_STRING",
|
if (WARN("SPLIT_STRING",
|
||||||
|
@ -4671,13 +4671,13 @@ sub process {
|
||||||
}
|
}
|
||||||
|
|
||||||
# concatenated string without spaces between elements
|
# concatenated string without spaces between elements
|
||||||
if ($line =~ /"X+"[A-Z_]+/ || $line =~ /[A-Z_]+"X+"/) {
|
if ($line =~ /$String[A-Z_]/ || $line =~ /[A-Za-z0-9_]$String/) {
|
||||||
CHK("CONCATENATED_STRING",
|
CHK("CONCATENATED_STRING",
|
||||||
"Concatenated strings should use spaces between elements\n" . $herecurr);
|
"Concatenated strings should use spaces between elements\n" . $herecurr);
|
||||||
}
|
}
|
||||||
|
|
||||||
# uncoalesced string fragments
|
# uncoalesced string fragments
|
||||||
if ($line =~ /"X*"\s*"/) {
|
if ($line =~ /$String\s*"/) {
|
||||||
WARN("STRING_FRAGMENTS",
|
WARN("STRING_FRAGMENTS",
|
||||||
"Consecutive strings are generally better as a single string\n" . $herecurr);
|
"Consecutive strings are generally better as a single string\n" . $herecurr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue