Voice ranges up to 31 (NumVoices & 31), so 1 << 31 is undefined
behavior in C as it shifts into the sign bit of a signed int.
Use 1U to make the shift well-defined.

Reported-by: Pavee Hui <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
---
 hw/audio/gusemu_mixer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/audio/gusemu_mixer.c b/hw/audio/gusemu_mixer.c
index 341995cfd19e..8dc4a68386b4 100644
--- a/hw/audio/gusemu_mixer.c
+++ b/hw/audio/gusemu_mixer.c
@@ -133,11 +133,11 @@ void gus_mixvoices(GUSEmuState * state, unsigned int 
playback_freq, unsigned int
                 }
                 if ((GUSvoice(wVSRVolRampControl) & 0xa000) == 0xa000)  /* 
volramp IRQ set and enabled? */
                 {
-                    GUSregd(voicevolrampirq) |= 1 << Voice;             /* set 
irq slot */
+                    GUSregd(voicevolrampirq) |= 1U << Voice;            /* set 
irq slot */
                 }
                 else
                 {
-                    GUSregd(voicevolrampirq) &= (~(1 << Voice));        /* 
clear irq slot */
+                    GUSregd(voicevolrampirq) &= ~(1U << Voice); /* clear irq 
slot */
                     GUSvoice(wVSRVolRampControl) &= 0x7f00;
                 }
 
@@ -164,11 +164,11 @@ void gus_mixvoices(GUSEmuState * state, unsigned int 
playback_freq, unsigned int
                 }
                 if ((GUSvoice(wVSRControl) & 0xa000) == 0xa000)    /* 
wavetable IRQ set and enabled? */
                 {
-                    GUSregd(voicewavetableirq) |= 1 << Voice;      /* set irq 
slot */
+                    GUSregd(voicewavetableirq) |= 1U << Voice;      /* set irq 
slot */
                 }
                 else
                 {
-                    GUSregd(voicewavetableirq) &= (~(1 << Voice)); /* clear 
irq slot */
+                    GUSregd(voicewavetableirq) &= ~(1U << Voice); /* clear irq 
slot */
                     GUSvoice(wVSRControl) &= 0x7f00;
                 }
 

-- 
2.56.0.rc0.29.g47ce80527c56


Reply via email to