[U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones)

Graeme Russ graeme.russ at gmail.com
Sat Apr 16 09:16:03 CEST 2011


On 14/04/11 19:14, Kumar Gala wrote:
>>> From this it is easy to find unused options (CONFIG_ARIA is found only as a
>> #define in include/configs/aria.h for example)
>>
>> So my RFC is twofold:
>> 1) Should we start to systematically remove unused options
>> 2) Should we centralise all options in a single README (or two, one for
>> standard CONFIG options and one for CONFIG_SYS options)?
> 
> Can you post data for which options are not used.  While I think automatic removal is harsh, I think something close to automatic is reasonable.
> 
> - k

OK, here are some quick stats:

Total CONFIG_ options : 5559
Total CONFIG_ options not documented(*)/ : 4907
Total CONFIG_ options not used in code(+) : 1136
Total CONFIG_ options not used in any board config : 645

(*) README moved into doc/ to make the count of documented options more
accurate
(+) i.e. only found in either doc/ or include/configs/

As you can see, there is scope for a LOT of code cleanup within the CONFIG_
namespace

Here is the script:

#!/bin/bash
INPUT=doc/README.configuration.options.list
OUTPUT1=doc/README.configuration.options.counted.code_usage
OUTPUT2=doc/README.configuration.options.counted.doc
OUTPUT3=doc/README.configuration.options.counted.config

echo "Catalogue Configuration Options"
grep -rhos "#define CONFIG.*" * | \
	sed 's/#define[ \t]*//' | \
	sed 's/^\([A-Za-z0-9_]*\).*/\1/' | \
	sort -u > $INPUT

echo "Counting usage of configuration options in code"
rm $OUTPUT1 2> /dev/null
for i in `cat $INPUT`
do
	x=${i}'\s'
	grep -rcs --exclude-dir=include/configs --exclude-dir=doc '\<'${i}'\>' * | \
	cut -d : -f 2 | \
	awk '{sum+=$1} END {printf("%d\t%s\n", sum, f);}' f=$i >> $OUTPUT1
done
sort -n $OUTPUT1 > tmp
rm $OUTPUT1 2> /dev/null
mv tmp $OUTPUT1


echo "Counting documented options"
rm $OUTPUT2 2> /dev/null
for i in `cat $INPUT`
do
	x=${i}'\s'
	grep -rcs '\<'${i}'\>' doc/* --exclude=README.configuration.* | \
	cut -d : -f 2 | \
	awk '{sum+=$1} END {printf("%d\t%s\n", sum, f);}' f=$i >> $OUTPUT2
done
sort -n $OUTPUT2 > tmp
rm $OUTPUT2 2> /dev/null
mv tmp $OUTPUT2

echo "Counting usage of configuration options in board configuration files"
rm $OUTPUT3 2> /dev/null
for i in `cat $INPUT`
do
	x=${i}'\s'
	grep -rcs '\<'${i}'\>' include/configs/* | \
	cut -d : -f 2 | \
	awk '{sum+=$1} END {printf("%d\t%s\n", sum, f);}' f=$i >> $OUTPUT3
done
sort -n $OUTPUT3 > tmp
rm $OUTPUT3 2> /dev/null
mv tmp $OUTPUT3

echo "Done"

Regards,

Graeme


More information about the U-Boot mailing list