[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <576420B0.3050203@iogearbox.net>
Date: Fri, 17 Jun 2016 18:09:20 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: Phil Sutter <phil@....cc>, Stephen Hemminger <shemming@...cade.com>
CC: netdev@...r.kernel.org
Subject: Re: [iproute PATCH 1/3] Use C99 style initializers everywhere
On 06/17/2016 05:56 PM, Phil Sutter wrote:
> This big patch was compiled by vimgrepping for memset calls and changing
> to C99 initializer if applicable.
>
> Calls to memset for struct rtattr pointer fields for parse_rtattr*()
> were just dropped since they are not needed.
>
> The changes here allowed the compiler to discover some unused variables,
> so get rid of them, too.
>
> Signed-off-by: Phil Sutter <phil@....cc>
> ---
> bridge/fdb.c | 29 +++++++------
> bridge/link.c | 16 +++----
> bridge/mdb.c | 19 ++++-----
> bridge/vlan.c | 19 ++++-----
> genl/ctrl.c | 48 +++++++++------------
> ip/ip6tunnel.c | 10 ++---
> ip/ipaddress.c | 31 ++++++--------
> ip/ipaddrlabel.c | 23 +++++-----
> ip/iplink.c | 67 ++++++++++++++---------------
> ip/iplink_can.c | 4 +-
> ip/ipmaddr.c | 27 +++++-------
> ip/ipmroute.c | 8 +---
> ip/ipneigh.c | 36 ++++++++--------
> ip/ipnetconf.c | 12 +++---
> ip/ipnetns.c | 45 ++++++++++---------
> ip/ipntable.c | 27 +++++-------
> ip/iproute.c | 85 ++++++++++++++++--------------------
> ip/iprule.c | 26 +++++------
> ip/iptoken.c | 21 ++++-----
> ip/iptunnel.c | 31 ++++----------
> ip/ipxfrm.c | 26 +++--------
> ip/link_gre.c | 22 +++++-----
> ip/link_gre6.c | 22 +++++-----
> ip/link_ip6tnl.c | 29 ++++++-------
> ip/link_iptnl.c | 26 +++++------
> ip/link_vti.c | 22 +++++-----
> ip/link_vti6.c | 22 +++++-----
> ip/xfrm_policy.c | 110 ++++++++++++++++++++++-------------------------
> ip/xfrm_state.c | 128 +++++++++++++++++++++++++++----------------------------
> lib/libnetlink.c | 74 ++++++++++++++------------------
> lib/ll_map.c | 1 -
> misc/arpd.c | 68 ++++++++++++++---------------
> misc/ss.c | 41 ++++++++----------
> tc/e_bpf.c | 7 +--
> tc/em_cmp.c | 4 +-
> tc/em_ipset.c | 4 +-
> tc/em_meta.c | 4 +-
> tc/em_nbyte.c | 4 +-
> tc/em_u32.c | 4 +-
> tc/f_flow.c | 3 --
> tc/f_flower.c | 3 +-
> tc/f_fw.c | 6 +--
> tc/f_route.c | 3 --
> tc/f_rsvp.c | 6 +--
> tc/f_u32.c | 12 ++----
> tc/m_action.c | 51 +++++++++-------------
> tc/m_bpf.c | 5 +--
> tc/m_csum.c | 4 +-
> tc/m_ematch.c | 4 +-
> tc/m_gact.c | 5 +--
> tc/m_ife.c | 5 +--
> tc/m_mirred.c | 7 +--
> tc/m_nat.c | 4 +-
> tc/m_pedit.c | 8 +---
> tc/m_police.c | 5 +--
> tc/q_atm.c | 3 +-
> tc/q_cbq.c | 22 +++-------
> tc/q_choke.c | 4 +-
> tc/q_codel.c | 3 +-
> tc/q_dsmark.c | 1 -
> tc/q_fifo.c | 4 +-
> tc/q_fq_codel.c | 3 +-
> tc/q_hfsc.c | 13 ++----
> tc/q_htb.c | 15 +++----
> tc/q_netem.c | 16 +++----
> tc/q_red.c | 4 +-
> tc/q_sfb.c | 17 ++++----
> tc/q_sfq.c | 4 +-
> tc/q_tbf.c | 4 +-
> tc/tc_bpf.c | 96 +++++++++++++++++------------------------
> tc/tc_class.c | 33 ++++++--------
> tc/tc_exec.c | 3 +-
> tc/tc_filter.c | 35 ++++++---------
> tc/tc_qdisc.c | 35 ++++++---------
> tc/tc_stab.c | 4 +-
> tc/tc_util.c | 3 +-
> 76 files changed, 699 insertions(+), 956 deletions(-)
[...]
Hmm, seems like a lot of stuff ...
[...]
> diff --git a/tc/tc_bpf.c b/tc/tc_bpf.c
> index 86c6069b68ec4..8a264531dcdd4 100644
> --- a/tc/tc_bpf.c
> +++ b/tc/tc_bpf.c
> @@ -86,13 +86,12 @@ static int bpf(int cmd, union bpf_attr *attr, unsigned int size)
> static int bpf_map_update(int fd, const void *key, const void *value,
> uint64_t flags)
> {
> - union bpf_attr attr;
> -
> - memset(&attr, 0, sizeof(attr));
> - attr.map_fd = fd;
> - attr.key = bpf_ptr_to_u64(key);
> - attr.value = bpf_ptr_to_u64(value);
> - attr.flags = flags;
> + union bpf_attr attr = {
> + .map_fd = fd,
> + .key = bpf_ptr_to_u64(key),
> + .value = bpf_ptr_to_u64(value),
> + .flags = flags
> + };
>
> return bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));
[...]
Please have a look at commit 8f80d450c3cb ("tc: fix compilation with old gcc (< 4.6)") ...
Your changes effectively revert them again. Here, and some other parts of the bpf frontend
code bits.
Thanks,
Daniel
Powered by blists - more mailing lists