All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tuomas Tynkkynen <tuomas@tuxera.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Whitelist scripting
Date: Tue, 6 Mar 2018 02:00:29 +0200	[thread overview]
Message-ID: <20180306020029.10bf6fd5@duuni> (raw)
In-Reply-To: <CAHCN7xLXd8_m1TctPM41GpCNTeS5w3eqFa7MLPED+xDGHNdO3w@mail.gmail.com>

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

      reply	other threads:[~2018-03-06  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05 20:08 [U-Boot] Whitelist scripting Adam Ford
2018-03-06  0:00 ` Tuomas Tynkkynen [this message]

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=20180306020029.10bf6fd5@duuni \
    --to=tuomas@tuxera.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.