summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2006-08-24 18:46:32 -0700
committerTrent Piepho <xyzzy@speakeasy.org>2006-08-24 18:46:32 -0700
commit46d06fbe2e7e63f51fd16e60ba0371ec1a90953a (patch)
treee2b356411b83345491a8f8aa04eb6534346b4c09
parent759f96753505b99e831aa263766f7f6caafa4394 (diff)
downloadmediapointer-dvb-s2-46d06fbe2e7e63f51fd16e60ba0371ec1a90953a.tar.gz
mediapointer-dvb-s2-46d06fbe2e7e63f51fd16e60ba0371ec1a90953a.tar.bz2
Add new script, check_config_defines.pl
From: Trent Piepho <xyzzy@speakeasy.org> This script will check source files against the v4l-dvb and kernel Kconfig files, to make sure that all CONFIG_XXX defines mentioned in the source files have corresponding config options in the Kconfig files. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
-rwxr-xr-xv4l/scripts/check_config_defines.pl62
1 files changed, 62 insertions, 0 deletions
diff --git a/v4l/scripts/check_config_defines.pl b/v4l/scripts/check_config_defines.pl
new file mode 100755
index 000000000..91643d23c
--- /dev/null
+++ b/v4l/scripts/check_config_defines.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+# Copyright (C) 2006 Trent Piepho <xyzzy@speakeasy.org>
+#
+# Look for lines in C files like "#ifdef CONFIG_SOME_KCONF_VAR" and make
+# sure CONFIG_SOME_KCONF_VAR is something that exists.
+
+if($#ARGV < 0) {
+ print "Usage: $0 kernel_dir [files to check ...]\n\n";
+ print "If no files are listed, checks all files from hg manifest\n";
+ exit;
+}
+$kdir = shift;
+
+if($#ARGV < 0) {
+ @ARGV = `hg manifest | cut "-d " -f3 | grep '.[ch]\$'`;
+ $? == 0 and die "Error getting manifest: $!";
+ chomp @ARGV;
+}
+
+sub readkconfig($$)
+{
+ my $fn = "$_[0]/$_[1]";
+ # Don't read the same kconfig file more than once
+ return if exists $kconfigs{$fn};
+ $kconfigs{$fn} = 1;
+# print "Reading $fn\n";
+ my $fh;
+ open $fh, '<', "$fn" or die "Can't read Kconfig file $fn: $!";
+ while(<$fh>) {
+ if (/^\s*source\s+"([^"]+)"\s*$/ || /^\s*source\s+(\S+)\s*$/) {
+ readkconfig($_[0], $1);
+ } elsif(/^config\s+(\w+)$/) {
+ $vars{"CONFIG_$1"}=1;
+ }
+ }
+ close $fh;
+}
+
+readkconfig('linux', 'drivers/media/Kconfig');
+foreach(glob "$kdir/arch/*/Kconfig") {
+ s|^\Q$kdir/\E||;
+ next if(m|arch/um/Kconfig|);
+ readkconfig($kdir, $_);
+}
+
+while(<>) {
+ if(/^\s*#ifdef\s+(CONFIG_\w+)(_MODULE)?\W*$/) {
+# print "Found $1\n";
+ print "Unknown config $1 in $ARGV:$.\n" unless(exists $vars{$1});
+ next;
+ }
+ if(/^\s*#if/) {
+ $_ .= <> while(/\\$/); # Handle line continuations
+ while(/defined\(\s*(CONFIG_\w+?)(_MODULE)?\s*\)/) {
+ print "Unknown config $1 in $ARGV:$.\n" unless(exists $vars{$1});
+ $_ = $';
+ }
+ }
+
+} continue {
+ close ARGV if eof;
+}