Re: [patch] sys_epoll 0.14 ...

Andrew Morton (akpm@digeo.com)
Tue, 29 Oct 2002 20:12:12 -0800


Davide Libenzi wrote:
>
> On Tue, 29 Oct 2002, Andrew Morton wrote:
>
> > I was referring to these guys:
> >
> > +#define list_first(head) (((head)->next != (head)) ? (head)->next: (struct list_head *) 0)
> > +#define list_last(head) (((head)->prev != (head)) ? (head)->prev: (struct list_head *) 0)
> > +#define list_next(pos, head) (((pos)->next != (head)) ? (pos)->next: (struct list_head *) 0)
> > +#define list_prev(pos, head) (((pos)->prev != (head)) ? (pos)->prev: (struct list_head *) 0)
> >
> > if we are to add such things to list.h then lots of people need
> > to hum and hah over them first and ask questions like "why doesn't
> > it use list_empty?" ;)
> >
> > It would be better to recode epoll's list walks to use the existing
> > list accessors.
>
> Andrew, don't they better describe what you're actually doing instead of
> the list_empty() trick ?
>

They are a reasonable addition to the list library. They
should be implemented as:

/*
* kernel-doc description goes here
*/
static inline struct list_head *list_first(struct list_head *list)
{
if (list_empty(list))
return NULL;
return list->next;
}

But it shouldn't be quietly snuck in as part of epoll. Everyone in
the world uses list.h.

Given that they are used in just a handful of places in epoll and nowhere
else in the kernel it is a little hard to justify adding them.

Unless people leap out and say "I've always wanted one of them" it would
be best to redo epoll to use

while (!list_empty(list)) {
item = list_entry(list, ...);
list_del(item->list);
...
}

or one of the other eighty-seven list helpers which we already have.
-
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/