lkml.org 
[lkml]   [2019]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 01/12] list.h: add a list_pop helper
On Mon, Jun 24, 2019 at 07:52:42AM +0200, Christoph Hellwig wrote:
> +/**
> + * list_pop - delete the first entry from a list and return it
> + * @list: the list to take the element from.
> + * @type: the type of the struct this is embedded in.
> + * @member: the name of the list_head within the struct.
> + *
> + * Note that if the list is empty, it returns NULL.
> + */
> +#define list_pop(list, type, member) \

The usual convention in list.h is that list_foo uses the list head and
list_foo_entry uses the container type. So I think this should be
renamed to list_pop_entry() at least. Do we also want:

static inline struct list_head *list_pop(struct list_head *head)
{
struct list_head *first = READ_ONCE(head->next);

if (first == head)
return NULL;
__list_del(head, first->next);
return first;
}

we also seem to prefer using inline functions over #defines in this
header file.

\
 
 \ /
  Last update: 2019-06-24 17:52    [W:0.206 / U:19.544 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site