public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Matteo Croce' <mcroce@linux.microsoft.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Julia Lawall <julia.lawall@inria.fr>
Subject: RE: [PATCH net-next v2 0/3] introduce skb_for_each_frag()
Date: Sat, 17 Apr 2021 11:07:55 +0000	[thread overview]
Message-ID: <3a3c006cc1c644fd8e2fe791dba5139a@AcuMS.aculab.com> (raw)
In-Reply-To: <CAFnufp12=8pDo-GP6BwH72YiH5C9GXOY8Me=xsFo7=+hvfujaQ@mail.gmail.com>

From: Matteo Croce
> Sent: 16 April 2021 23:44
...
> > A more interesting change would be something that generated:
> >         unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
> >         for (i = 0; i < nr_frags; i++) {
> > since that will run faster for most loops.
> > But that is ~impossible to do since you can't declare
> > variables inside the (...) that are scoped to the loop.
> >
> 
> I don't know how to do it with C90.
> It would be nice to have a switch to just allow declaration of
> variables inside the (...) instead of enabling the full C99 language
> which, as Linus said[1], allows the insane mixing of variables and
> code.
> 
> [1] https://lore.kernel.org/lkml/CA+55aFzs=DuYibWYMUFiU_R1aJHAr-8hpQhWLew8R5q4nCDraQ@mail.gmail.com/

Quoting Linus:

> I *like* getting warnings for confused people who start introducing
> variables in the middle of blocks of code. That's not well-contained
> like the loop variable.

The really stupid part of C99 is that such variables can alias
ones in an outer block.
Aliased definitions are bad enough at the best of times.
Makes it very easy to miss the correct definition when reading code.

I much prefer local variables to either function scope or be
defined for very local use at the top of a very small block.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

      reply	other threads:[~2021-04-17 11:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12  0:37 [PATCH net-next v2 0/3] introduce skb_for_each_frag() Matteo Croce
2021-04-12  0:38 ` [PATCH net-next v2 1/3] skbuff: add helper to walk over the fraglist Matteo Croce
2021-04-12  0:38 ` [PATCH net-next v2 2/3] net: use skb_for_each_frag() helper where possible Matteo Croce
2021-04-12  7:40   ` Eric Dumazet
2021-04-12  0:38 ` [PATCH net-next v2 3/3] net: use skb_for_each_frag() in illegal_highdma() Matteo Croce
2021-04-13  7:53 ` [PATCH net-next v2 0/3] introduce skb_for_each_frag() David Laight
2021-04-16 22:44   ` Matteo Croce
2021-04-17 11:07     ` David Laight [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=3a3c006cc1c644fd8e2fe791dba5139a@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=davem@davemloft.net \
    --cc=julia.lawall@inria.fr \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcroce@linux.microsoft.com \
    --cc=netdev@vger.kernel.org \
    /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