[U-Boot] Whitelist scripting

Tuomas Tynkkynen tuomas at tuxera.com
Tue Mar 6 00:00:29 UTC 2018


Hi,

On Mon, 5 Mar 2018 14:08:20 -0600
Adam Ford <aford173 at 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


More information about the U-Boot mailing list