From: "Pablo M. Bermudo Garay" <pablombg@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Phil Sutter <phil@nwl.cc>, Pablo Neira Ayuso <pablo@netfilter.org>
Subject: Re: [nft PATCH] mnl: Remove dead code
Date: Mon, 7 Aug 2017 18:54:48 +0200 [thread overview]
Message-ID: <CAAaDf4umkgnqEr+mxXBCwhh+tpQ8xW8ENepMcv3aMoAdDnj7xQ@mail.gmail.com> (raw)
In-Reply-To: <20170727084646.GB5576@salvia>
[-- Attachment #1: Type: text/plain, Size: 1948 bytes --]
2017-07-27 10:46 GMT+02:00 Pablo Neira Ayuso <pablo@netfilter.org>:
> Cc'ing Pablo Bermudo.
>
> On Wed, Jul 26, 2017 at 06:16:30PM +0200, Phil Sutter wrote:
>> Remove the functions mnl_nft_rule_add() and *_delete() since they are
>> not used throughout the code. Commit a72315d2bad47 ("src: add rule
>> batching support") changed their only caller to use the batch variant
>> introduced at the same time.
>
> I think there are more useless functions. Pablo Bermudo mentioned this
> to me a while ago. At least I remember some of them in netlink.c?
>
> If not much asking, it would be good if we can kill them all in one go.
I am using a combination of compiler and linker options in order to obtain
a list of unused functions:
$ make -j5 CFLAGS="-ffunction-sections -fdata-sections
-Wl,--gc-sections,--print-gc-sections"
You can find more information about --gc-sections and its pitfalls here [1].
The listing is printed on stderr by --print-gc-sections and it looks like this:
/usr/bin/ld: Removing unused section '.text.xt_stmt_xlate' in file 'statement.o'
/usr/bin/ld: Removing unused section '.text.xt_stmt_release' in file
'statement.o'
/usr/bin/ld: Removing unused section '.text.xt_stmt_print' in file 'statement.o'
...
There is also a small utility called callcatcher [2], written by LibreOffice
developer Caolán McNamara. But it seems not to be recursive, so unused
functions invoked from other unused functions are not shown until the callers
are deleted.
The complete list contains some functions that I think are not worth removing,
because are part of a "consolidated API" (e.g. those related to the
implementation of the red–black tree). A bunch of unused functions are
from the auto-generated file scanner.c.
The current list is attached.
--
[1] http://elinux.org/images/2/2d/ELC2010-gc-sections_Denys_Vlasenko.pdf
[2] http://www.skynet.ie/~caolan/Packages/callcatcher.html
[-- Attachment #2: nft-unused-code --]
[-- Type: application/octet-stream, Size: 1770 bytes --]
# Unused struct
xt_stmt_ops in file 'statement.c'
# Unused functions
chain_get_cb in file 'mnl.c'
cli_display in file 'cli.c'
mnl_nft_chain_get in file 'mnl.c'
mnl_nft_rule_add in file 'mnl.c'
mnl_nft_rule_delete in file 'mnl.c'
mnl_nft_set_get in file 'mnl.c'
mnl_nft_table_get in file 'mnl.c'
mpz_get_be64 in file 'gmputil.c'
netlink_add_rule_list in file 'netlink.c'
netlink_dump_table in file 'netlink.c'
netlink_get_chain in file 'netlink.c'
netlink_get_set in file 'netlink.c'
netlink_get_table in file 'netlink.c'
netlink_list_chain in file 'netlink.c'
nft_set_lval in file 'scanner.c'
rb_last in file 'rbtree.c'
rb_prev in file 'rbtree.c'
rb_replace_node in file 'rbtree.c'
set_get_cb in file 'mnl.c'
table_get_cb in file 'mnl.c'
xt_stmt_alloc in file 'statement.c'
xt_stmt_destroy in file 'statement.c'
xt_stmt_print in file 'statement.c'
xt_stmt_release in file 'statement.c'
xt_stmt_xlate in file 'statement.c'
nft_get_column in file 'scanner.c'
nft_get_debug in file 'scanner.c'
nft_get_in in file 'scanner.c'
nft_get_leng in file 'scanner.c'
nft_get_lineno in file 'scanner.c'
nft_get_lloc in file 'scanner.c'
nft_get_lval in file 'scanner.c'
nft_get_out in file 'scanner.c'
nft_get_text in file 'scanner.c'
nft_lex_init_extra in file 'scanner.c'
nft_set_column in file 'scanner.c'
nft_set_in in file 'scanner.c'
nft_set_lineno in file 'scanner.c'
nft_set_lloc in file 'scanner.c'
prev parent reply other threads:[~2017-08-07 16:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-26 16:16 [nft PATCH] mnl: Remove dead code Phil Sutter
2017-07-27 8:46 ` Pablo Neira Ayuso
2017-08-07 16:54 ` Pablo M. Bermudo Garay [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=CAAaDf4umkgnqEr+mxXBCwhh+tpQ8xW8ENepMcv3aMoAdDnj7xQ@mail.gmail.com \
--to=pablombg@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
/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.