qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] intc/i8259: avoid (false positive) gcc warning


From: Christian Borntraeger
Subject: [PATCH] intc/i8259: avoid (false positive) gcc warning
Date: Thu, 18 Mar 2021 16:47:38 +0100

some copiler 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;
       |         ~~~~^~~~~~~~~~

Let us initialize irq2 to -1 to avoid this warning as the most simple
solution.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 hw/intc/i8259.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
index 344fd04db14d..ade6fb726faf 100644
--- a/hw/intc/i8259.c
+++ b/hw/intc/i8259.c
@@ -176,7 +176,7 @@ 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, irq2 = -1, intno;
 
     irq = pic_get_irq(s);
     if (irq >= 0) {
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]