lkml.org 
[lkml]   [2013]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] list: add while_list_drain_entry
On Tue, Jun 04, 2013 at 10:03:41PM -0400, Jörn Engel wrote:
> I have seen a lot of boilerplate code that either follows the pattern of
> while (!list_empty(head)) {
> pos = list_entry(head->next, struct foo, list);
> list_del(pos->list);
> ...
> }
> or some variant thereof.
>
> With this patch in, people can use
> while_list_drain_entry(pos, head, list) {
> ...
> }

The while_list_drain_entry way changes the semantics: the list link is
deleted before the {...} body starts, so it's not possible to access the
list anymore. None of the code you've converted uses this, from that
point it's safe, but if this is about to be a public interface, it
should be (at least) documented.

Macro trickery to postpone list_del after the {...} finishes does not
work if kfree/kmem_cache_free/rcu_string_free/... is used.


david
--
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-05 18:01    [W:0.062 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site