d5c9f7ed99bd09648fdecc195d0d5640128f8c2c
[sfrench/samba-autobuild/.git] / source4 / script / find_unused_options.sh
1 #!/bin/sh
2 #
3 # this script finds unused lp_*() functions
4 #
5 # use it like this:
6 #
7 #   user@host:~/samba/source>./script/find_unused_options.sh
8 #
9
10 LIST_GLOBAL=`grep '^FN_GLOBAL' param/loadparm.c |sed -e's/^FN_GLOBAL.*(\(.*\).*,.*\(&Globals\..*\)).*/\1:\2/'`
11
12 LIST_LOCAL=`grep '^FN_LOCAL' param/loadparm.c |sed -e's/^FN_LOCAL.*(\(.*\).*,[ ]*\(.*\)).*/\1:\2/'`
13
14 for i in $LIST_GLOBAL;do
15         key=`echo $i|cut -d ':' -f1`
16         val=`echo $i|cut -d ':' -f2`
17
18         found=`grep "$key[ ]*()" */*.c`
19
20         if test -z "$found"; then
21             found=`grep "$key[ ]*()" */*/*.c`
22             if test -z "$found"; then
23                 echo "Not Used Global: $key() -> $val"
24             fi
25         fi
26 done
27
28 for i in $LIST_LOCAL;do
29         key=`echo $i|cut -d ':' -f1`
30         val=`echo $i|cut -d ':' -f2`
31
32         found=`grep "$key[ ]*(" */*.c`
33
34         if test -z "$found"; then
35             found=`grep "$key[ ]*(" */*/*.c`
36             if test -z "$found"; then
37                 echo "Not Used LOCAL: $key() -> $val"
38             fi
39         fi
40 done
41
42 echo "# do a 'make clean;make everything' before removing anything!"