aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkkconfigsymbols.sh
diff options
context:
space:
mode:
authorPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>2007-08-25 03:45:28 -0400
committerSam Ravnborg <sam@neptun.(none)>2007-10-12 15:13:50 -0400
commit0bce67352b580e9025059ecc71e13e0ffd281254 (patch)
tree1528e7fbeed10b04b3013a9dffb26acf28c1aee4 /scripts/checkkconfigsymbols.sh
parentaa1e5ef5c1d95e7ebf0821d9ba27debe43a87a22 (diff)
kbuild: script to check for undefined Kconfig symbols
To avoid having to look manually for used but undefined Kconfig variables, I've written a script which tries do this efficiently, in case all other attention fail. It accounts for _MODULE suffix and for UML_ prefixes to Kconfig variable, but otherwise looks for exact matches (i.e. \<CONFIG_; this is done to exclude macros like MMCONFIG_). Undefined Kconfig variables should be not be removed without care, but for instance arch/i386/boot/ uses a bunch of undefined Kconfig vars: $ scripts/checkunknowndefines.sh arch/i386/boot/ arch/i386/boot/video.h uses undefined symbol VIDEO_400_HACK arch/i386/boot/video-vga.c uses undefined symbol VIDEO_400_HACK arch/i386/boot/video.c uses undefined symbol VIDEO_RETAIN arch/i386/boot/video.h uses undefined symbol VIDEO_RETAIN arch/i386/boot/video.h uses undefined symbol VIDEO_SVGA arch/i386/boot/video.h uses undefined symbol VIDEO_VESA arch/i386/boot/video-vesa.c uses undefined symbol VIDEO_VESA It should also be mentioned in SubmittingPatches and SubmitChecklist. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Roman Zippel <zippel@linux-m68k.org> Cc: Adrian Bunk <bunk@stusta.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/checkkconfigsymbols.sh')
-rwxr-xr-xscripts/checkkconfigsymbols.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/scripts/checkkconfigsymbols.sh b/scripts/checkkconfigsymbols.sh
new file mode 100755
index 000000000000..39677c82747a
--- /dev/null
+++ b/scripts/checkkconfigsymbols.sh
@@ -0,0 +1,59 @@
1#!/bin/sh
2# Find Kconfig variables used in source code but never defined in Kconfig
3# Copyright (C) 2007, Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
4
5# Tested with dash.
6paths="$@"
7[ -z "$paths" ] && paths=.
8
9# Doing this once at the beginning saves a lot of time, on a cache-hot tree.
10Kconfigs="`find . -name 'Kconfig' -o -name 'Kconfig*[^~]'`"
11
12echo -e "File list \tundefined symbol used"
13find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while read i
14do
15 # Output the bare Kconfig variable and the filename; the _MODULE part at
16 # the end is not removed here (would need perl an not-hungry regexp for that).
17 sed -ne 's!^.*\<\(UML_\)\?CONFIG_\([0-9A-Z_]\+\).*!\2 '$i'!p' < $i
18done | \
19# Smart "sort|uniq" implemented in awk and tuned to collect the names of all
20# files which use a given symbol
21awk '{map[$1, count[$1]++] = $2; }
22END {
23 for (combIdx in map) {
24 split(combIdx, separate, SUBSEP);
25 # The value may have been removed.
26 if (! ( (separate[1], separate[2]) in map ) )
27 continue;
28 symb=separate[1];
29 printf "%s ", symb;
30 #Use gawk extension to delete the names vector
31 delete names;
32 #Portably delete the names vector
33 #split("", names);
34 for (i=0; i < count[symb]; i++) {
35 names[map[symb, i]] = 1;
36 # Unfortunately, we may still encounter symb, i in the
37 # outside iteration.
38 delete map[symb, i];
39 }
40 i=0;
41 for (name in names) {
42 if (i > 0)
43 printf ", %s", name;
44 else
45 printf "%s", name;
46 i++;
47 }
48 printf "\n";
49 }
50}' |
51while read symb files; do
52 # Remove the _MODULE suffix when checking the variable name. This should
53 # be done only on tristate symbols, actually, but Kconfig parsing is
54 # beyond the purpose of this script.
55 symb_bare=`echo $symb | sed -e 's/_MODULE//'`
56 if ! grep -q "\<$symb_bare\>" $Kconfigs; then
57 echo -e "$files: \t$symb"
58 fi
59done|sort