lkml.org 
[lkml]   [2003]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] list.h: implement list_for_each_entry_safe
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:35    [W:0.046 / U:0.696 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site