Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
checkpatch: add test for #defines of ARCH_HAS_<foo>
Browse files Browse the repository at this point in the history
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>
Git-commit: 52ea850
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
  • Loading branch information
JoePerches authored and Stepan Moskovchenko committed Oct 10, 2014
1 parent aa86dac commit cfa353b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,14 @@ sub rtrim {
return $string;
}

sub string_find_replace {
my ($string, $find, $replace) = @_;

$string =~ s/$find/$replace/g;

return $string;
}

sub tabify {
my ($leading) = @_;

Expand Down Expand Up @@ -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)
if ($line =~ /(\b$InitAttribute\b)/) {
my $attr = $1;
Expand Down Expand Up @@ -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);
}

# 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
my $string;
while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
Expand Down

0 comments on commit cfa353b

Please sign in to comment.