]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ALSA: riptide: clean up while loop
authorDan Carpenter <error27@gmail.com>
Wed, 3 Mar 2010 07:13:49 +0000 (10:13 +0300)
committerTakashi Iwai <tiwai@suse.de>
Wed, 3 Mar 2010 21:41:42 +0000 (22:41 +0100)
If getpaths() returned an odd number this would be a buffer under-run and an
endless loop.  It turns out that getpaths() can only return even numbers, but
let's make it easy for people auditing code.  With the new code you don't
need to look at getpaths().

This silences a smatch warning.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/riptide/riptide.c

index 960a227eb6531795bbbdbdfa8430238939079a5c..ad44626776153019a4a491351c472fba25765908 100644 (file)
@@ -1974,9 +1974,9 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
        }
        snd_iprintf(buffer, "Paths:\n");
        i = getpaths(cif, p);
-       while (i--) {
-               snd_iprintf(buffer, "%x->%x ", p[i - 1], p[i]);
-               i--;
+       while (i >= 2) {
+               i -= 2;
+               snd_iprintf(buffer, "%x->%x ", p[i], p[i + 1]);
        }
        snd_iprintf(buffer, "\n");
 }