The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
To: "David S. Miller" <davem@redhat.com>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] list.h: implement list_for_each_entry_safe
Date: Sun, 4 May 2003 18:24:38 -0300	[thread overview]
Message-ID: <20030504212438.GA14414@conectiva.com.br> (raw)
In-Reply-To: <1052052632.27465.0.camel@rth.ninka.net>

Em Sun, May 04, 2003 at 05:50:32AM -0700, David S. Miller escreveu:
> On Sun, 2003-05-04 at 00:57, Arnaldo Carvalho de Melo wrote:
> > ChangeSet@1.1219, 2003-05-04 04:39:21-03:00, acme@conectiva.com.br
> >   o list.h: implement list_for_each_entry_safe
> 
> Exists already, there is even a _rcu version.

Huh? Where is that? :-)

There is list_for_each_entry and list_for_each_entry_rcu, but not
list_for_each_entry_safe nor, for that matter, list_for_each_entry_safe_rcu.

list_for_each_entry was introduced not so long ago by Rusty, AFAIK, so that we
can simplify traversing lists that before, with just list_for_each & _safe and
_rcu variations required that we use a struct list_head as the loop iteration
variable and have as well another variable of the type contained in the list,
like this:

struct llc_sap *llc_sap_find(u8 sap_value)
{
        struct llc_sap* sap = NULL;
        struct list_head *entry;

        list_for_each(entry, &llc_main_station.sap_list.list) {
                sap = list_entry(entry, struct llc_sap, node);
                if (sap->laddr.lsap == sap_value)
                        goto out;
        }
	sap = NULL;
out:
        return sap;
}

Using the _entry variation this can (and will) be converted to

struct llc_sap *llc_sap_find(u8 sap_value)
{
        struct llc_sap* sap;

        list_for_each_entry(sap, &llc_main_station.sap_list.list, node)
                if (sap->laddr.lsap == sap_value)
                        goto out;
	sap = NULL;
out:
        return sap;
}

But then we need (at least I need for IPX, maybe others) the _entry_safe (and
most likely, at least initially for completeness, the _entry_safe_rcu)
variations. This is what I'm submitting :)

- Arnaldo

  reply	other threads:[~2003-05-04 21:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-04  7:57 [PATCH] list.h: implement list_for_each_entry_safe Arnaldo Carvalho de Melo
2003-05-04 12:50 ` David S. Miller
2003-05-04 21:24   ` Arnaldo Carvalho de Melo [this message]
2003-05-04 20:19     ` David S. 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=20030504212438.GA14414@conectiva.com.br \
    --to=acme@conectiva.com.br \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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