Skip to contentSkip to conversation

hw/audio/intel-hda: Avoid shift into sign bit

PATCH In review Peter Maydell 2 participants 2 messages May 9, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/audio/intel-hda: Avoid shift into sign bit

Add a U suffix to avoid shifting into the sign bit (which is undefined behaviour in C).

---
Another one from clang's sanitizer...

 hw/audio/intel-hda.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/audio/intel-hda.c +2 -2
index d41f82c..0cec2d2 100644
@@ -245,7 +245,7 @@ static void intel_hda_update_int_sts(IntelHDAState *d)
 
     /* update global status */
     if (sts & d->int_ctl) {
-        sts |= (1 << 31);
+        sts |= (1U << 31);
     }
 
     d->int_sts = sts;
@@ -257,7 +257,7 @@ static void intel_hda_update_irq(IntelHDAState *d)
     int level;
 
     intel_hda_update_int_sts(d);
-    if (d->int_sts & (1 << 31) && d->int_ctl & (1 << 31)) {
+    if (d->int_sts & (1U << 31) && d->int_ctl & (1U << 31)) {
         level = 1;
     } else {
         level = 0;
Signature · 1 line
1.9.2
#1 lore raw
Quoted 2 lines · Peter Maydell

Add a U suffix to avoid shifting into the sign bit (which is undefined behaviour in C).

Added to audio patch queue.

thanks,
Gerd