public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] Whitelist scripting
@ 2018-03-05 20:08 Adam Ford
  2018-03-06  0:00 ` Tuomas Tynkkynen
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Ford @ 2018-03-05 20:08 UTC (permalink / raw)
  To: u-boot

I went through my boards to look for junk #defines in the header that
do nothing and/or are dead.
I then created a pretty poor script that runs through and scans the
whitelist and greps the code searching for C code that uses the
defines.

I started isolating sections and found that in some places we have C
code that does the check for a #define, but it never gets defined
anywhere, and in other places, we have #defines that aren't used.

What I was hoping to do was help clean the whitelist table by first
searching for #defines that are never used anywhere and/or are dead.I
will be the first person to admit that I am not very good with shell
scripts, so I thought I'd solicit a favor.

Does someone have any cool scripts that we can use the scan through
the and look for #defines that have no #ifdef, Makefile dependancy, or
linker script attachment?  These seem like they'd be obvious chunks of
code to eliminate.

Conversely, does anyone have any cool scripts that we can scan through
the code and look for #ifdefs that are never defined?  Those seem like
other low-hanging fruit but possible still useful.

As people are going through and using moveconfig to migrate to Kconfig
it seems like there might be a lot of work saved by eliminating a junk
from the whitelist.

adam

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

* [U-Boot] Whitelist scripting
  2018-03-05 20:08 [U-Boot] Whitelist scripting Adam Ford
@ 2018-03-06  0:00 ` Tuomas Tynkkynen
  0 siblings, 0 replies; 2+ messages in thread
From: Tuomas Tynkkynen @ 2018-03-06  0:00 UTC (permalink / raw)
  To: u-boot

Hi,

On Mon, 5 Mar 2018 14:08:20 -0600
Adam Ford <aford173@gmail.com> wrote:

...
> 
> What I was hoping to do was help clean the whitelist table by first
> searching for #defines that are never used anywhere and/or are dead.I
> will be the first person to admit that I am not very good with shell
> scripts, so I thought I'd solicit a favor.
> 
> Does someone have any cool scripts that we can use the scan through
> the and look for #defines that have no #ifdef, Makefile dependancy, or
> linker script attachment?  These seem like they'd be obvious chunks of
> code to eliminate.

I personally started with a lower-hanging fruit: config symbols that
are referenced exactly once. For that I use the following hacks
that I just pick from the shell history with Ctrl-R every now and then :)

rm -rf grep-counts; mkdir grep-counts; for f in $(cat scripts/config_whitelist.txt); do git grep $f > grep-counts/$f; done

This just builds a "database" of occurences for each symbol in the whitelist. Then:

for f in $(wc -l grep-counts/* | awk '$1 == 2' | tr / ' ' | awk '{print $3}'); do cat grep-counts/$f; done | grep ':#define'

This lists all the symbols from the database that are only #define'd exactly once
(it checks for '2' to account for the match in config_whitelist.txt).

Hope that helps. Don't try to remove the same symbols I removed in my latest 3
patches to the list though :)

- Tuomas

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

end of thread, other threads:[~2018-03-06  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-05 20:08 [U-Boot] Whitelist scripting Adam Ford
2018-03-06  0:00 ` Tuomas Tynkkynen

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