diff options
author | Joe Perches <joe@perches.com> | 2013-11-12 18:10:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-12 22:09:24 -0500 |
commit | 52ea85061d188031c827ecef9bce47ae93f1e52e (patch) | |
tree | 613a13b5542918ea5a0b08c992bddcbd81453b76 /scripts/checkpatch.pl | |
parent | 11ea516a6c578564a65a352abb08ef558d365946 (diff) |
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: Joe Perches <joe@perches.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
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-x | scripts/checkpatch.pl | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index fcc74fe7b4d9..8489c35799e8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -1514,6 +1514,14 @@ sub rtrim { | |||
1514 | return $string; | 1514 | return $string; |
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | sub string_find_replace { | ||
1518 | my ($string, $find, $replace) = @_; | ||
1519 | |||
1520 | $string =~ s/$find/$replace/g; | ||
1521 | |||
1522 | return $string; | ||
1523 | } | ||
1524 | |||
1517 | sub tabify { | 1525 | sub tabify { |
1518 | my ($leading) = @_; | 1526 | my ($leading) = @_; |
1519 | 1527 | ||
@@ -3733,14 +3741,6 @@ sub process { | |||
3733 | } | 3741 | } |
3734 | } | 3742 | } |
3735 | 3743 | ||
3736 | sub string_find_replace { | ||
3737 | my ($string, $find, $replace) = @_; | ||
3738 | |||
3739 | $string =~ s/$find/$replace/g; | ||
3740 | |||
3741 | return $string; | ||
3742 | } | ||
3743 | |||
3744 | # check for bad placement of section $InitAttribute (e.g.: __initdata) | 3744 | # check for bad placement of section $InitAttribute (e.g.: __initdata) |
3745 | if ($line =~ /(\b$InitAttribute\b)/) { | 3745 | if ($line =~ /(\b$InitAttribute\b)/) { |
3746 | my $attr = $1; | 3746 | my $attr = $1; |
@@ -4198,6 +4198,12 @@ sub string_find_replace { | |||
4198 | "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); | 4198 | "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); |
4199 | } | 4199 | } |
4200 | 4200 | ||
4201 | # Use of __ARCH_HAS_<FOO> or ARCH_HAVE_<BAR> is wrong. | ||
4202 | if ($line =~ /\+\s*#\s*define\s+((?:__)?ARCH_(?:HAS|HAVE)\w*)\b/) { | ||
4203 | ERROR("DEFINE_ARCH_HAS", | ||
4204 | "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr); | ||
4205 | } | ||
4206 | |||
4201 | # check for %L{u,d,i} in strings | 4207 | # check for %L{u,d,i} in strings |
4202 | my $string; | 4208 | my $string; |
4203 | while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) { | 4209 | while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) { |