[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <200805241748.19607.m.kozlowski@tuxland.pl>
Date: Sat, 24 May 2008 17:48:19 +0200
From: Mariusz Kozlowski <m.kozlowski@...land.pl>
To: kernel-janitors@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Subject: some numbers on macros
Hello,
I wrote a rather dumb script to see some numbers on macros I was
interested in. The script basically parses *.c file, finds macro definitions
and counts how many times each macro was used in this source file. The script
doesn't see any context so it can produce false positives - that is one of
the reasons it doesn't look into header files - it's simply too dumb.
The macros I was interested in were these which are:
- defined and unused
- defined and used only once
- defined more than once
I dont want to start another cleanup-patches-storm so first I'd like to
know if this excersise is worth it as unused macros do not do much harm.
Would such patches be accepted?
Mariusz
example on recent linux-2.6 snapshot:
$ ./find_interesting_macros.php linux-2.6
[snip]
10189 files to parse
used defined macro
[snip]
0 1 'Tracev' /home/mariusz/linux/linux-2.6/init/initramfs.c +400
0 1 'Tracevv' /home/mariusz/linux/linux-2.6/init/initramfs.c +401
0 1 'Tracec' /home/mariusz/linux/linux-2.6/init/initramfs.c +402
0 1 'Tracecv' /home/mariusz/linux/linux-2.6/init/initramfs.c +403
1 1 'version_string' /home/mariusz/linux/linux-2.6/init/version.c +17
8 2 'DBG' /home/mariusz/linux/linux-2.6/sound/soc/at91/at91-ssc.c +39
4 2 'DBG' /home/mariusz/linux/linux-2.6/sound/soc/at91/at91-pcm.c +37
8 2 'DBG' /home/mariusz/linux/linux-2.6/sound/soc/at91/eti_b1_wm8731.c +44
25 2 'DBG' /home/mariusz/linux/linux-2.6/sound/soc/s3c24xx/s3c2412-i2s.c +49
21 2 'DBG' /home/mariusz/linux/linux-2.6/sound/soc/s3c24xx/s3c24xx-i2s.c +49
19 2 'DBG' /home/mariusz/linux/linux-2.6/sound/soc/s3c24xx/s3c24xx-pcm.c +42
0 2 'dbg' /home/mariusz/linux/linux-2.6/sound/soc/codecs/wm8750.c +41
1 1 'info' /home/mariusz/linux/linux-2.6/sound/soc/codecs/wm8750.c +48
0 1 'warn' /home/mariusz/linux/linux-2.6/sound/soc/codecs/wm8750.c +50
1 1 'wm8750_reset' /home/mariusz/linux/linux-2.6/sound/soc/codecs/wm8750.c +120
0 2 'dbg' /home/mariusz/linux/linux-2.6/sound/soc/codecs/wm8731.c +41
1 1 'info' /home/mariusz/linux/linux-2.6/sound/soc/codecs/wm8731.c +48
0 1 'warn' /home/mariusz/linux/linux-2.6/sound/soc/codecs/wm8731.c +50
1 1 'wm8731_reset' /home/mariusz/linux/linux-2.6/sound/soc/codecs/wm8731.c +120
...
BTW. How many unused macros are in *.c files?
$ ./find_interesting_macros.php linux-2.6 | grep "^0" | wc -l
1340
Well ... since it produces some false positives the real number can differ a little.
This is an example of a macro that will cause false positive:
scripts/kconfig/kconfig_load.c +7
#define P(name,type,arg) type (*name ## _p) arg
#include "lkc_proto.h"
#undef P
Download attachment "find_interesting_macros.php" of type "application/x-php" (3895 bytes)
Powered by blists - more mailing lists