Commit 52ea8506 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

checkpatch: add test for #defines of ARCH_HAS_<foo>

Add a test for these #defines

Additionally, moved string_find_replace sub as it screws up subsequent
formatting when placed inside another sub.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Suggested-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 11ea516a
...@@ -1514,6 +1514,14 @@ sub rtrim { ...@@ -1514,6 +1514,14 @@ sub rtrim {
return $string; return $string;
} }
sub string_find_replace {
my ($string, $find, $replace) = @_;
$string =~ s/$find/$replace/g;
return $string;
}
sub tabify { sub tabify {
my ($leading) = @_; my ($leading) = @_;
...@@ -3733,14 +3741,6 @@ sub process { ...@@ -3733,14 +3741,6 @@ sub process {
} }
} }
sub string_find_replace {
my ($string, $find, $replace) = @_;
$string =~ s/$find/$replace/g;
return $string;
}
# check for bad placement of section $InitAttribute (e.g.: __initdata) # check for bad placement of section $InitAttribute (e.g.: __initdata)
if ($line =~ /(\b$InitAttribute\b)/) { if ($line =~ /(\b$InitAttribute\b)/) {
my $attr = $1; my $attr = $1;
...@@ -4198,6 +4198,12 @@ sub string_find_replace { ...@@ -4198,6 +4198,12 @@ sub string_find_replace {
"usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
} }
# Use of __ARCH_HAS_<FOO> or ARCH_HAVE_<BAR> is wrong.
if ($line =~ /\+\s*#\s*define\s+((?:__)?ARCH_(?:HAS|HAVE)\w*)\b/) {
ERROR("DEFINE_ARCH_HAS",
"#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr);
}
# check for %L{u,d,i} in strings # check for %L{u,d,i} in strings
my $string; my $string;
while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) { while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment