@@ -40,7 +40,7 @@ foreach my $file (@files) {
&check_asm_types();
&check_sizetypes();
&check_declarations();
- # Dropped for now. Too much noise &check_config();
+ &check_config();
}
close $fh;
}
@@ -76,9 +76,24 @@ sub check_declarations
}
}
+my $check_config_in_multiline_comment = 0;
sub check_config
{
- if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+ my $nocomments = $line;
+ $nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+ $nocomments =~ s/\/\/.*//; # Remove C99-style comments (// to EOL)
+
+ # Check to see if we're within a multiline comment, and if so
+ # just remove the whole line. I tried matching on '^ * ', but
+ # there's one header that doesn't prepend multi-line comments
+ # with * so that won't work.
+ if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+ if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+ if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+ # Check to see if there is something that looks like CONFIG_
+ # inside a userspace-accessible header file and if so, print that out.
+ if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
}
}