lkml.org 
[lkml]   [2006]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: list corruption on removal of snd_seq_dummy
At Tue, 27 Jun 2006 08:05:01 -0400,
Chuck Ebbert wrote:
>
> In-Reply-To: <s5hejxb7xrb.wl%tiwai@suse.de>
>
> On Tue, 27 Jun 2006 11:28:56 +0200, Takashi Iwai wrote:
>
> > > > > The code in question is doing..
> > > > >
> > > > > __list_add(&deleted_list,
> > > > > client->ports_list_head.prev,
> > > > > client->ports_list_head.next);
> > > > >
> > > > > which looks fishy, as those two elements aren't going to be consecutive,
> > > > > as __list_add expects.
> > > >
> > > > I think the code behaves correctly but probably misusing __list_add().
> > > > It movies the whole entries from an existing list_head A
> > > > (clients->ports_list_head) to a new list_head B (deleted_list).
> > > > The above is exapnded:
> > > >
> > > > A->next->prev = B;
> > > > B->next = A->next;
> > > > B->prev = A->prev;
> > > > A->prev->next = B;
> > > >
> > > > Any better way to achieve it using standard macros?
> > >
> > > Why can't you just list_move() the elements ?
> >
> > No, list_move() can't move the whole elements without loop.
> >
> > A solution is
> >
> > list_add(B, A);
> > list_del_init(A);
> >
> > (although this introduces a bit more code :)
>
> Shouldn't it be like this?
>
> ports_list_first = client->ports_list_head.next;
> list_del_init(client->ports_list_head);
> list_splice(ports_list_first, &deleted_list);

This requires INIT_LIST_HEAD(&deleted_list) first, so obviously
a longer code :)


Takashi
-
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/

\
 
 \ /
  Last update: 2006-06-27 14:41    [W:0.343 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site