lkml.org 
[lkml]   [2013]   [Jun]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 0/2] introduce list_for_each_entry_del
On Mon, 3 June 2013 15:36:47 -0400, Jörn Engel wrote:
> On Mon, 3 June 2013 13:49:30 -0700, Christoph Hellwig wrote:
> >
> > I can't say I like the structure.
> >
> > A list_pop that removes and entry from the head or returns NULL if the
> > list is empty would lead to nice while loops that are obviously
> > readable instead.
>
> Something like this?
>
> #define list_pop(head) \
> ({ struct list_head *____pos; \
> list_empty(head) ? NULL : (____pos = (head)->next, \
> list_del(____pos), ____pos) \
> })
>
> #define list_pop_entry(head, type, member) \
> ({ struct list_head *____pos; \
> list_empty(head) ? NULL : (____pos = (head)->next, \
> list_del(____pos), list_entry(____pos, type, member) \
> })
>
> Would be fine with me as well.

Actually, when I compare the two invocations, I prefer the
list_for_each_entry_del() variant over list_pop_entry().

while ((ref = list_pop_entry(&prefs, struct __prelim_ref, list))) {
list_for_each_entry_del(ref, &prefs, list) {

Christoph?

Jörn

--
"Translations are and will always be problematic. They inflict violence
upon two languages." (translation from German)
--
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: 2013-06-04 00:01    [W:1.148 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site