]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ALSA: pcm: Avoid confusing loop in snd_pcm_unlink()
authorTakashi Iwai <tiwai@suse.de>
Sun, 13 Jan 2019 09:19:32 +0000 (10:19 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 21 Jan 2019 15:40:19 +0000 (16:40 +0100)
The snd_pcm_group_for_each_entry() loop found in snd_pcm_unlink() is
only for taking the first list entry.  Use list_first_entry() to make
clearer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm_native.c

index 1a56bb1ad7804b7f942ac4f0088507ec3f2ddac4..fb45386270d5a1523ccb43f7e1f32a60dd33f344 100644 (file)
@@ -2023,7 +2023,6 @@ static void relink_to_local(struct snd_pcm_substream *substream)
 
 static int snd_pcm_unlink(struct snd_pcm_substream *substream)
 {
-       struct snd_pcm_substream *s;
        struct snd_pcm_group *group;
        int res = 0;
 
@@ -2040,10 +2039,9 @@ static int snd_pcm_unlink(struct snd_pcm_substream *substream)
 
        /* detach the last stream, too */
        if (list_is_singular(&group->substreams)) {
-               snd_pcm_group_for_each_entry(s, substream) {
-                       relink_to_local(s);
-                       break;
-               }
+               relink_to_local(list_first_entry(&group->substreams,
+                                                struct snd_pcm_substream,
+                                                link_list));
                kfree(group);
        }