Re: [patch 2/16] list_head debugging

Andrew Morton
2002-06-03T20:19:22Z

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.