Skip to content
Snippets Groups Projects
Commit 7717f248 authored by Jia Liu's avatar Jia Liu
Browse files

hw/openrisc: Avoid undefined shift in openrisc_pic_cpu_handler()


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: default avatarXi Wang <xi.wang@gmail.com>
Acked-by: default avatarJia Liu <proljc@gmail.com>
parent ed396e2b
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment