Re: [patch 2/16] list_head debugging

From: Andrew Morton (akpm@zip.com.au)
Date: Mon Jun 03 2002 - 15:16:49 EST


Jan Harkes wrote:
>
> On Sat, Jun 01, 2002 at 01:40:03AM -0700, Andrew Morton wrote:
> > The patch nulls out the dangling pointers so we get a nice oops at the
> > site of the buggy code.
> ...
> > static __inline__ void list_del(struct list_head *entry)
> > {
> > __list_del(entry->prev, entry->next);
> > + /*
> > + * This is debug. Remove it when the kernel has no bugs ;)
> > + */
> > + entry->next = 0;
> > + entry->prev = 0;
> > }
>
> We've had this before, and it breaks some code that removes items from
> lists as follows,
>
> list_for_each(p, list)
> if (condition)
> list_del(p);

hmm. I suppose that's sane.

> These would have to either use __list_del, or need to do,
>
> for(p = list.next; p != &list;) {
> struct list_head *n = p->next;
> if (condition)
> list_del(p);
> p = n;
> }

list_for_each_safe() does this.
-
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/



This archive was generated by hypermail 2b29 : Fri Jun 07 2002 - 22:00:16 EST