summaryrefslogtreecommitdiff
path: root/source4/script/find_unused_options.sh
blob: d5c9f7ed99bd09648fdecc195d0d5640128f8c2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
#
# this script finds unused lp_*() functions
#
# use it like this:
#
#   user@host:~/samba/source>./script/find_unused_options.sh
#

LIST_GLOBAL=`grep '^FN_GLOBAL' param/loadparm.c |sed -e's/^FN_GLOBAL.*(\(.*\).*,.*\(&Globals\..*\)).*/\1:\2/'`

LIST_LOCAL=`grep '^FN_LOCAL' param/loadparm.c |sed -e's/^FN_LOCAL.*(\(.*\).*,[ ]*\(.*\)).*/\1:\2/'`

for i in $LIST_GLOBAL;do
	key=`echo $i|cut -d ':' -f1`
	val=`echo $i|cut -d ':' -f2`

	found=`grep "$key[ ]*()" */*.c`

	if test -z "$found"; then
	    found=`grep "$key[ ]*()" */*/*.c`
	    if test -z "$found"; then
		echo "Not Used Global: $key() -> $val"
	    fi
	fi
done

for i in $LIST_LOCAL;do
	key=`echo $i|cut -d ':' -f1`
	val=`echo $i|cut -d ':' -f2`

	found=`grep "$key[ ]*(" */*.c`

	if test -z "$found"; then
	    found=`grep "$key[ ]*(" */*/*.c`
	    if test -z "$found"; then
		echo "Not Used LOCAL: $key() -> $val"
	    fi
	fi
done

echo "# do a 'make clean;make everything' before removing anything!"