All of lore.kernel.org
 help / color / mirror / Atom feed
From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones)
Date: Sat, 16 Apr 2011 17:16:03 +1000	[thread overview]
Message-ID: <4DA94233.2040301@gmail.com> (raw)
In-Reply-To: <FC3C7371-366D-47CE-A41F-A9C2E21BFF10@kernel.crashing.org>

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

  reply	other threads:[~2011-04-16  7:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-11 13:11 [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones) Graeme Russ
2011-04-14  6:17 ` Albert ARIBAUD
2011-04-14  8:36   ` Graeme Russ
2011-04-14  9:14 ` Kumar Gala
2011-04-16  7:16   ` Graeme Russ [this message]
2011-04-17 13:30     ` Timur Tabi
2011-04-17 19:26       ` Graeme Russ

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DA94233.2040301@gmail.com \
    --to=graeme.russ@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.