public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* some numbers on macros
@ 2008-05-24 15:48 Mariusz Kozlowski
  2008-05-24 16:33 ` Arjan van de Ven
  0 siblings, 1 reply; 6+ messages in thread
From: Mariusz Kozlowski @ 2008-05-24 15:48 UTC (permalink / raw)
  To: kernel-janitors; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3258 bytes --]

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


[-- Attachment #2: find_interesting_macros.php --]
[-- Type: application/x-php, Size: 3894 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-05-25  9:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-24 15:48 some numbers on macros Mariusz Kozlowski
2008-05-24 16:33 ` Arjan van de Ven
2008-05-24 18:52   ` Matthew Wilcox
2008-05-24 23:41     ` Mariusz Kozlowski
2008-05-24 23:46       ` Arjan van de Ven
2008-05-25  9:11         ` Mariusz Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox