]> git.proxmox.com Git - qemu.git/commitdiff
oss/alsa: Do not invoke UB described in 7.15.1.1 (this time for ADC)
authormalc <av1474@comtv.ru>
Fri, 2 Oct 2009 23:30:06 +0000 (03:30 +0400)
committermalc <av1474@comtv.ru>
Fri, 2 Oct 2009 23:30:18 +0000 (03:30 +0400)
Signed-off-by: malc <av1474@comtv.ru>
audio/alsaaudio.c
audio/ossaudio.c

index 0ef89e98e613cecb34914040e654d7dfd6e734c1..7698d1010bde2f732ab820a2ec16df5b7179bb12 100644 (file)
@@ -1079,23 +1079,26 @@ static int alsa_read (SWVoiceIn *sw, void *buf, int size)
 
 static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...)
 {
-    va_list ap;
-    int poll_mode;
     ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
 
-    va_start (ap, cmd);
-    poll_mode = va_arg (ap, int);
-    va_end (ap);
-
     switch (cmd) {
     case VOICE_ENABLE:
-        ldebug ("enabling voice\n");
-        if (poll_mode && alsa_poll_in (hw)) {
-            poll_mode = 0;
-        }
-        hw->poll_mode = poll_mode;
+        {
+            va_list ap;
+            int poll_mode;
 
-        return alsa_voice_ctl (alsa->handle, "capture", 0);
+            va_start (ap, cmd);
+            poll_mode = va_arg (ap, int);
+            va_end (ap);
+
+            ldebug ("enabling voice\n");
+            if (poll_mode && alsa_poll_in (hw)) {
+                poll_mode = 0;
+            }
+            hw->poll_mode = poll_mode;
+
+            return alsa_voice_ctl (alsa->handle, "capture", 0);
+        }
 
     case VOICE_DISABLE:
         ldebug ("disabling voice\n");
index dae25e93ab2239d7398cbd0f1e4dd170c39b65eb..4002f146706d48cfbf2c387b56b4d7435c182d1e 100644 (file)
@@ -781,20 +781,23 @@ static int oss_read (SWVoiceIn *sw, void *buf, int size)
 
 static int oss_ctl_in (HWVoiceIn *hw, int cmd, ...)
 {
-    va_list ap;
-    int poll_mode;
     OSSVoiceIn *oss = (OSSVoiceIn *) hw;
 
-    va_start (ap, cmd);
-    poll_mode = va_arg (ap, int);
-    va_end (ap);
-
     switch (cmd) {
     case VOICE_ENABLE:
-        if (poll_mode && oss_poll_in (hw)) {
-            poll_mode = 0;
+        {
+            va_list ap;
+            int poll_mode;
+
+            va_start (ap, cmd);
+            poll_mode = va_arg (ap, int);
+            va_end (ap);
+
+            if (poll_mode && oss_poll_in (hw)) {
+                poll_mode = 0;
+            }
+            hw->poll_mode = poll_mode;
         }
-        hw->poll_mode = poll_mode;
         break;
 
     case VOICE_DISABLE: