Skip to contentSkip to conversation

list corruption on removal of snd_seq_dummy

DISCUSSION Chuck Ebbert 3 participants 4 messages Jun 27, 2006

lore
Share & tools
lore
#0 lore raw

In-Reply-To: <s5hejxb7xrb.wl%[email protected]>

Quoted 23 lines · Takashi Iwai
Quoted 14 lines
Quoted 14 lines
Quoted 8 lines

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:

Quoted 8 lines
Quoted 6 lines

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 ?

Quoted 8 lines

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);
Signature · 2 lines
Chuck
 "You can't read a newspaper if you can't read."  --George W. Bush
#1 lore raw

At Tue, 27 Jun 2006 08:05:01 -0400,

Quoted 35 lines · Chuck Ebbert

In-Reply-To: <s5hejxb7xrb.wl%[email protected]>

Quoted 30 lines · Takashi Iwai
Quoted 14 lines
Quoted 14 lines
Quoted 8 lines

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:

Quoted 8 lines
Quoted 6 lines

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);
Quoted 7 lines
Quoted 1 line

(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

Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

#2 lore raw
Quoted 9 lines · Takashi Iwai
Quoted 9 lines
Quoted 8 lines

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 :)

Quoted 8 lines
Quoted 5 lines

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 :)

This is hardly a speed/size critical function. I'd go for readability over cute hacks any day.

Dave

Signature · 6 lines
http://www.codemonkey.org.uk

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
#3 lore raw

At Tue, 27 Jun 2006 12:58:19 -0400,

Quoted 17 lines · Dave Jones
Quoted 15 lines · Takashi Iwai
Quoted 14 lines
Quoted 8 lines

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);
Quoted 5 lines
Quoted 2 lines

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

This is hardly a speed/size critical function. I'd go for readability over cute hacks any day.

Yeah, of course.
The code was already fixed on ALSA tree to use standard macros.

Takashi

Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642