Re: [PATCH] hlist_for_each_safe cleanup

From: Stephen Hemminger
Date: Fri Jul 23 2004 - 17:57:20 EST


On Fri, 23 Jul 2004 23:22:23 +0200
Andreas Schwab <schwab@xxxxxxx> wrote:

> Stephen Hemminger <shemminger@xxxxxxxx> writes:
>
> > --- linux-2.6/include/linux/list.h 2004-07-23 09:36:18.000000000 -0700
> > +++ tcp-2.6/include/linux/list.h 2004-07-23 11:43:25.000000000 -0700
> > @@ -620,13 +620,12 @@
> >
> > #define hlist_entry(ptr, type, member) container_of(ptr,type,member)
> >
> > -/* Cannot easily do prefetch unfortunately */
> > #define hlist_for_each(pos, head) \
> > for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
> > pos = pos->next)
> >
> > #define hlist_for_each_safe(pos, n, head) \
> > - for (pos = (head)->first; n = pos ? pos->next : NULL, pos; \
> > + for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
>
> What's wrong with using the comma operator instead of non-standard
> statement expressions?

It was more a case of consistency and avoiding the n = NULL assignment when pos
is NULL.

Look at hlist_for_each_entry_safe

#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
for (pos = (head)->first; \
pos && ({ n = pos->next; 1; }) && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = n)


What's your problem with the gcc extensions, the kernel uses them all over the place,
planning on starting a conversion?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/