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-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html