[lkml]   [2012]   [Apr]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: hlist_for_each_entry && pos (Was: task_work_queue)
On Wed, Apr 11, 2012 at 9:00 PM, Oleg Nesterov <> wrote:
> This reminds me.
> hlist_for_each_entry_*() do not need "pos", it can be
>        #define hlist_for_each_entry(pos, head, member)                                 \
>                for (pos = (void*)(head)->first;                                        \
>                pos && ({ pos = hlist_entry((void*)pos, typeof(*pos), member); 1; });   \
>                pos = (void*)(pos)->

Ugh. I'm not sure that is any better, with the extra casts to hide the
fact that you use the wrong type pointers for it.

Are there any code generation improvements?

Because quite frankly, if there aren't, I think the code churn just
isn't worth it - especially with how ugly the macro is.

This is one of those things where the C99 features would actually be
nice: one of the few features from C++ that I actually liked is the
ability to declare the induction variable. So

#define hlist_for_each_entry(pos, head, member) \
for (void *__pos = (head)->first; \
__pos && ({ pos = hlist_entry(__pos, typeof(*pos), member); 1; });   \
__pos = __pos->next)

would actually be prettier. That said, "pretty macro" isn't very high
on the list of things to worry about. Not nearly as high as the pain
changing the interface would cause for things that *should* be trivial
(like backporting patches etc).

So I'd really want to see some more tangible advantage.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2012-04-12 06:15    [W:0.050 / U:2.388 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site