]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/openrisc: Avoid undefined shift in openrisc_pic_cpu_handler()
authorJia Liu <proljc@gmail.com>
Wed, 21 Aug 2013 01:31:36 +0000 (09:31 +0800)
committerJia Liu <proljc@gmail.com>
Wed, 21 Aug 2013 01:31:42 +0000 (09:31 +0800)
In C99 signed shift (1 << 31) is undefined behavior, since the result
exceeds INT_MAX.  Use 1U instead and move the shift after the check.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Acked-by: Jia Liu <proljc@gmail.com>
hw/openrisc/pic_cpu.c

index 3fcee0261978bd544651a54a40888e0c19d4cd6c..2af1d6013ad5f64a6b890fc70c2e8594b2b4e58f 100644 (file)
@@ -26,12 +26,14 @@ static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)
 {
     OpenRISCCPU *cpu = (OpenRISCCPU *)opaque;
     CPUState *cs = CPU(cpu);
-    uint32_t irq_bit = 1 << irq;
+    uint32_t irq_bit;
 
     if (irq > 31 || irq < 0) {
         return;
     }
 
+    irq_bit = 1U << irq;
+
     if (level) {
         cpu->env.picsr |= irq_bit;
     } else {