netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: xemul@sw.ru
Cc: netdev@vger.kernel.org, dev@sw.ru
Subject: Re: [PATCH] Rework dev_base via list_head
Date: Thu, 03 May 2007 03:25:40 -0700 (PDT)	[thread overview]
Message-ID: <20070503.032540.101470158.davem@davemloft.net> (raw)
In-Reply-To: <463894E8.6090204@sw.ru>

From: Pavel Emelianov <xemul@sw.ru>
Date: Wed, 02 May 2007 17:40:56 +0400

> Cleanup of dev_base list use, with the aim to simplify making
> device list per-namespace. In almost every occasion, use of
> dev_base variable and dev->next pointer could be easily replaced
> by  for_each_netdev loop. A few most complicated places were
> converted to using first_netdev()/next_netdev().
> 
> Fits 2.6.21-rc7 tree.
> 
> Signed-off-by: Pavel Emelianov <xemul@openvz.org>
> Acked-by: Kirill Korotaev <dev@openvz.org>

Overall this looks mostly good.

One thing I want to audit before applying this is
loop termination conditions.

With the old loop, if you do something like this:

	for (dev = dev_base; dev; dev = dev->next) {
		if (dev == what_I_want)
			break;
	}

you can test for a successful find after the loop with:

	if (dev) {
		I_found_it();
	}

That doesn't work with for_each_netdev(), if the loop
runs till the end of the list, the iterator will not
be left at NULL.

I just want to make sure you didn't leave any code around which wants
that behavior still.

This is one of the subtle things about using the list iterators in
linux/list.h, vs. a traditional by-hand singly linked list
implementation.

  reply	other threads:[~2007-05-03 10:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-02 13:40 [PATCH] Rework dev_base via list_head Pavel Emelianov
2007-05-03 10:25 ` David Miller [this message]
2007-05-03 10:42   ` Pavel Emelianov
2007-05-03 10:39     ` David Miller

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=20070503.032540.101470158.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dev@sw.ru \
    --cc=netdev@vger.kernel.org \
    --cc=xemul@sw.ru \
    /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).