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

Hi All,
As a bit of a lark, I ran the following shell command:
grep -r -h -o -G "#define CONFIG.*" * | \ sed 's/#define[ \t]*//' | \ sed 's/^([A-Za-z0-9_]*).*/\1/' | \ sort -u > README.configuration.options
I then ran the result through the following script into README.configuration.options.counted
#!/bin/bash INPUT=doc/README.configuration.options
#!/bin/bash INPUT=doc/README.configuration.options
for i in `cat $INPUT` do grep -rcs --exclude-dir=doc '<'${i}'>' * | \ cut -d : -f 2 | \ awk '{sum+=$1} END {printf("%d\t%s\n", sum, f);}' f=$i done
The result? 5539 lines of pure configuration option goodness :)
Here's a little snippet:
6 CONFIG_100MHz 8 CONFIG_133MHZ_DRAM 7 CONFIG_300MHz 13 CONFIG_405 24 CONFIG_405CR 88 CONFIG_405EP 81 CONFIG_405EX
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)?
Regards,
Graeme

Hi Graeme,
Le 11/04/2011 15:11, Graeme Russ a écrit :
So my RFC is twofold:
- Should we start to systematically remove unused options
I would tend to answer 'yes'. Unused options should not clobber code or documentation.
- Should we centralise all options in a single README (or two, one for
standard CONFIG options and one for CONFIG_SYS options)?
That would be nice indeed, but it requires all options to have the same semantics over all arches. While this is highly desirable, it may not be true ATM -- just thinking out loud, haven't checked. But even if some options only make sense only for some arch(es), then we could always do it this way:
doc/README.CONFIG_options doc/README.CONFIG_SYS_options doc/arch/README.CONFIG_options
Regards,
Graeme
Amicalement,

On 14/04/11 16:17, Albert ARIBAUD wrote:
Hi Graeme,
Le 11/04/2011 15:11, Graeme Russ a écrit :
So my RFC is twofold:
- Should we start to systematically remove unused options
I would tend to answer 'yes'. Unused options should not clobber code or documentation.
- Should we centralise all options in a single README (or two, one for
standard CONFIG options and one for CONFIG_SYS options)?
That would be nice indeed, but it requires all options to have the same semantics over all arches. While this is highly desirable, it may not be true ATM -- just thinking out loud, haven't checked. But even if some options only make sense only for some arch(es), then we could always do it this way:
doc/README.CONFIG_options doc/README.CONFIG_SYS_options doc/arch/README.CONFIG_options
Hmm, I have a better idea after I can to the realisation that the central location for configuration options is Ctrl^F in the doc/ directory :)
doc/README.CONFIG_options.unused doc/README.CONFIG_options.undocumented
I will tweak my scripts to produce these two files and see what the result is.
Regards,
Graeme

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:
- Should we start to systematically remove unused options
- 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

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:
- Should we start to systematically remove unused options
- 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

On Sat, Apr 16, 2011 at 2:16 AM, Graeme Russ graeme.russ@gmail.com wrote:
#!/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
How about Makefiles? Sometimes a CONFIG option is used only in a Makefiles.

On Sunday, April 17, 2011, Timur Tabi timur@freescale.com wrote:
On Sat, Apr 16, 2011 at 2:16 AM, Graeme Russ graeme.russ@gmail.com wrote:
#!/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
How about Makefiles? Sometimes a CONFIG option is used only in a Makefiles.
code_usage includes Makefiles
Regards,
Graeme
participants (4)
-
Albert ARIBAUD
-
Graeme Russ
-
Kumar Gala
-
Timur Tabi