[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 7/8] hw/intc/i8259: Refactor pic_read_irq() to avoid uninitialized
From: |
Paolo Bonzini |
Subject: |
[PULL 7/8] hw/intc/i8259: Refactor pic_read_irq() to avoid uninitialized variable |
Date: |
Fri, 19 Mar 2021 10:39:23 -0400 |
From: Philippe Mathieu-Daudé <philmd@redhat.com>
Some compiler versions are smart enough to detect a potentially
uninitialized variable, but are not smart enough to detect that this
cannot happen due to the code flow:
../hw/intc/i8259.c: In function ‘pic_read_irq’:
../hw/intc/i8259.c:203:13: error: ‘irq2’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
203 | irq = irq2 + 8;
| ~~~~^~~~~~~~~~
Restrict irq2 variable use to the inner statement.
Fixes: 78ef2b6989f ("i8259: Reorder intack in pic_read_irq")
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210318163059.3686596-1-philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/intc/i8259.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
index 344fd04db1..cc4e21ffec 100644
--- a/hw/intc/i8259.c
+++ b/hw/intc/i8259.c
@@ -176,10 +176,12 @@ static void pic_intack(PICCommonState *s, int irq)
int pic_read_irq(DeviceState *d)
{
PICCommonState *s = PIC_COMMON(d);
- int irq, irq2, intno;
+ int irq, intno;
irq = pic_get_irq(s);
if (irq >= 0) {
+ int irq2;
+
if (irq == 2) {
irq2 = pic_get_irq(slave_pic);
if (irq2 >= 0) {
@@ -189,20 +191,18 @@ int pic_read_irq(DeviceState *d)
irq2 = 7;
}
intno = slave_pic->irq_base + irq2;
+ pic_intack(s, irq);
+ irq = irq2 + 8;
} else {
intno = s->irq_base + irq;
+ pic_intack(s, irq);
}
- pic_intack(s, irq);
} else {
/* spurious IRQ on host controller */
irq = 7;
intno = s->irq_base + irq;
}
- if (irq == 2) {
- irq = irq2 + 8;
- }
-
#ifdef DEBUG_IRQ_LATENCY
printf("IRQ%d latency=%0.3fus\n",
irq,
--
2.26.2
- [PULL 0/8] Misc bugfixes for QEMU soft freeze, Paolo Bonzini, 2021/03/19
- [PULL 1/8] qom: use qemu_printf to print help for user-creatable objects, Paolo Bonzini, 2021/03/19
- [PULL 3/8] target/i386: fail if toggling LA57 in 64-bit mode, Paolo Bonzini, 2021/03/19
- [PULL 2/8] target/i386: allow modifying TCG phys-addr-bits, Paolo Bonzini, 2021/03/19
- [PULL 8/8] tests/qtest: cleanup the testcase for bug 1878642, Paolo Bonzini, 2021/03/19
- [PULL 6/8] i386: Make migration fail when Hyper-V reenlightenment was enabled but 'user_tsc_khz' is unset, Paolo Bonzini, 2021/03/19
- [PULL 7/8] hw/intc/i8259: Refactor pic_read_irq() to avoid uninitialized variable,
Paolo Bonzini <=
- [PULL 4/8] target/i386: svm: do not discard high 32 bits of EXITINFO1, Paolo Bonzini, 2021/03/19
- [PULL 5/8] i386: Fix 'hypercall_hypercall' typo, Paolo Bonzini, 2021/03/19
- Re: [PULL 0/8] Misc bugfixes for QEMU soft freeze, no-reply, 2021/03/19
- Re: [PULL 0/8] Misc bugfixes for QEMU soft freeze, Peter Maydell, 2021/03/20
- Re: [PULL 0/8] Misc bugfixes for QEMU soft freeze, Thomas Huth, 2021/03/22