netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: David Laight <David.Laight@ACULAB.COM>
Cc: Stephen Hemminger <shemming@brocade.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [iproute PATCH 05/12] ip{,6}tunnel: align do_tunnels_list() a bit
Date: Fri, 13 Nov 2015 18:53:03 +0100	[thread overview]
Message-ID: <20151113175303.GC22380@orbit.nwl.cc> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1CBD1126@AcuExch.aculab.com>

On Fri, Nov 13, 2015 at 05:30:10PM +0000, David Laight wrote:
> From: Phil Sutter
> > Sent: 13 November 2015 17:09
> > In iptunnel, declare loop variables inside the loop as done in
> > ip6tunnel.
> ...
> > @@ -396,14 +396,8 @@ static void print_tunnel(struct ip_tunnel_parm *p)
> > 
> >  static int do_tunnels_list(struct ip_tunnel_parm *p)
> >  {
> > -	char name[IFNAMSIZ];
> > -	unsigned long  rx_bytes, rx_packets, rx_errs, rx_drops,
> > -	rx_fifo, rx_frame,
> > -	tx_bytes, tx_packets, tx_errs, tx_drops,
> > -	tx_fifo, tx_colls, tx_carrier, rx_multi;
> > -	struct ip_tunnel_parm p1;
> > -
> ...
> >  	while (fgets(buf, sizeof(buf), fp) != NULL) {
> > +		char name[IFNAMSIZ];
> >  		int index, type;
> > +		unsigned long rx_bytes, rx_packets, rx_errs, rx_drops,
> > +			rx_fifo, rx_frame,
> > +			tx_bytes, tx_packets, tx_errs, tx_drops,
> > +			tx_fifo, tx_colls, tx_carrier, rx_multi;
> > +		struct ip_tunnel_parm p1;
> >  		char *ptr;
> > +
> 
> Personally I find that just makes it harder to find where the
> variables are defined.

Well, the above aligns the code with ip/ip6tunnel.c in that particular
matter. I'm neither a friend of the old nor the new version, so if
everyone thinks it is better without this patch, I'm fine with changing
ip/ip6tunnel.c accordingly as well.

Looking at the code again, maybe the better option overall would be to
export the whole file reading and stats printing code into a shared
function.

> Since the linux kernel cannot be compiled with -Wshadow declaring
> variables in inner scopes can easily lead to very strange bugs.

Well, since this is not kernel code but iproute2 one, we *could* compile
it with -Wshadow.

Thanks, Phil

  reply	other threads:[~2015-11-13 17:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-13 17:08 [iproute PATCH 00/12] smaller iptunnel and ip6tunnel review Phil Sutter
2015-11-13 17:08 ` [iproute PATCH 01/12] ip{,6}tunnel: get rid of extraneous whitespace when printing Phil Sutter
2015-11-13 17:08 ` [iproute PATCH 02/12] ip/tunnel: introduce tnl_parse_key() Phil Sutter
2015-11-13 17:08 ` [iproute PATCH 03/12] ip{,6}tunnel: unify behaviour if physical device is not found Phil Sutter
2015-11-13 17:08 ` [iproute PATCH 04/12] iptunnel: use ll_name_to_index() for physical interface lookup Phil Sutter
2015-11-13 17:08 ` [iproute PATCH 05/12] ip{,6}tunnel: align do_tunnels_list() a bit Phil Sutter
2015-11-13 17:30   ` David Laight
2015-11-13 17:53     ` Phil Sutter [this message]
2015-11-13 17:08 ` [iproute PATCH 06/12] ip6tunnel: print local/remote addresses like iptunnel does Phil Sutter
2015-11-13 17:09 ` [iproute PATCH 07/12] ip6tunnel: fix coding style: no newline between brace and else Phil Sutter
2015-11-13 17:09 ` [iproute PATCH 08/12] iptunnel: share common code when setting tunnel mode Phil Sutter
2015-11-13 17:09 ` [iproute PATCH 09/12] iptunnel: simplify parsing TTL, allow 'hlim' as identifier Phil Sutter
2015-11-13 17:09 ` [iproute PATCH 10/12] iptunnel: share common code when determining the default interface name Phil Sutter
2015-11-13 17:09 ` [iproute PATCH 11/12] iptunnel: sanitize copying tunnel name Phil Sutter
2015-11-13 17:09 ` [iproute PATCH 12/12] ip{,6}tunnel: put spaces around non-unary operators Phil Sutter
2015-11-23 23:28 ` [iproute PATCH 00/12] smaller iptunnel and ip6tunnel review Stephen Hemminger

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=20151113175303.GC22380@orbit.nwl.cc \
    --to=phil@nwl.cc \
    --cc=David.Laight@ACULAB.COM \
    --cc=netdev@vger.kernel.org \
    --cc=shemming@brocade.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).