[PATCH] headers_check: enable check for CONFIG_ leakage

From: Paul Bolle
Date: Tue Feb 04 2014 - 16:22:48 EST


The check for leaked CONFIG_ symbols was disabled in v2.6.30, because it
generated too much noise. But a (rather simplistic) preprocessing of
comments suffices to silence the noise (ie, no false positives are
reported anymore).

So add some preprocessing of comments and enable check_config() again.

Signed-off-by: Paul Bolle <pebolle@xxxxxxxxxx>
---
scripts/headers_check.pl | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
index b6aec5e4365f..8e67017c1b67 100755
--- a/scripts/headers_check.pl
+++ b/scripts/headers_check.pl
@@ -36,13 +36,36 @@ foreach my $file (@files) {
open(my $fh, '<', $filename)
or die "$filename: $!\n";
$lineno = 0;
+ my $in_comment = 0;
+ my $swap_state = 0;
while ($line = <$fh>) {
$lineno++;
- &check_include();
- &check_asm_types();
- &check_sizetypes();
- &check_declarations();
- # Dropped for now. Too much noise &check_config();
+
+ # strip inline comments
+ $line =~ s|/\*.*\*/||;
+
+ # try to handle multi line comments
+ if ($in_comment == 0 and $line =~ m|/\*|) {
+ $line =~ s|/\*.*$||;
+ # we still need to check (the first half of) this line
+ # so we set $in_comment after the checks
+ $swap_state = 1;
+ }
+ if ($in_comment == 1 and $line =~ m|\*/|) {
+ $line =~ s|^.*\*/||;
+ $in_comment = 0;
+ }
+ unless ($in_comment) {
+ check_include();
+ check_asm_types();
+ check_sizetypes();
+ check_declarations();
+ check_config();
+ }
+ if ($swap_state) {
+ $in_comment = 1;
+ $swap_state = 0;
+ }
}
close $fh;
}
--
2.17.2