* compile warning in i8259.c
@ 2021-03-15 15:14 Christian Borntraeger
2021-03-15 15:42 ` Thomas Huth
2021-03-15 15:44 ` Christian Borntraeger
0 siblings, 2 replies; 12+ messages in thread
From: Christian Borntraeger @ 2021-03-15 15:14 UTC (permalink / raw)
To: qemu-devel, qemu-s390x
For some time now I do see the following, when I compile x86-softmmu on s390:
FAILED: libcommon.fa.p/hw_intc_i8259.c.o
cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/capstone -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/libusb-1.0 -I/usr/include/vte-2.91 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -I/usr/include/virgl -I/usr/include/p11-kit-1 -I/usr/include/SDL2 -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/slirp -fdiagnostics-color=auto -pipe -Wall -Winvalid-pch -Werror -std=gnu99 -O2 -g -isystem /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers -iquote . -iquote /home/cborntra/REPOS/qemu -iquote /home/cborntra/REPOS/qemu/include -iquote /home/cborntra/REPOS/qemu/disas/libvixl -iquote /home/cborntra/REPOS/qemu/tcg/s390 -iquote /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIC -DSTRUCT_IOVEC_DEFINED -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ libcommon.fa.p/hw_intc_i8259.c.o -MF libcommon.fa.p/hw_intc_i8259.c.o.d -o libcommon.fa.p/hw_intc_i8259.c.o -c ../hw/intc/i8259.c
../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;
| ~~~~^~~~~~~~~~
cc1: all warnings being treated as errors
Due to other compile warnings I find this hard to bisect. Has anyone seen this as well?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 15:14 compile warning in i8259.c Christian Borntraeger
@ 2021-03-15 15:42 ` Thomas Huth
2021-03-15 15:46 ` Christian Borntraeger
2021-03-15 15:50 ` Philippe Mathieu-Daudé
2021-03-15 15:44 ` Christian Borntraeger
1 sibling, 2 replies; 12+ messages in thread
From: Thomas Huth @ 2021-03-15 15:42 UTC (permalink / raw)
To: Christian Borntraeger, qemu-devel, qemu-s390x
On 15/03/2021 16.14, Christian Borntraeger wrote:
> For some time now I do see the following, when I compile x86-softmmu on s390:
>
> FAILED: libcommon.fa.p/hw_intc_i8259.c.o
> cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader
> -I/usr/include/capstone -I/usr/include/glib-2.0
> -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid
> -I/usr/include/gio-unix-2.0 -I/usr/include/libusb-1.0
> -I/usr/include/vte-2.91 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz
> -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi
> -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1
> -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0
> -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0
> -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -I/usr/include/virgl
> -I/usr/include/p11-kit-1 -I/usr/include/SDL2 -I/usr/include/cacard
> -I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/slirp
> -fdiagnostics-color=auto -pipe -Wall -Winvalid-pch -Werror -std=gnu99 -O2 -g
> -isystem /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers
> -iquote . -iquote /home/cborntra/REPOS/qemu -iquote
> /home/cborntra/REPOS/qemu/include -iquote
> /home/cborntra/REPOS/qemu/disas/libvixl -iquote
> /home/cborntra/REPOS/qemu/tcg/s390 -iquote
> /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE
> -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
> -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
> -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common
> -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits
> -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body
> -Wnested-externs -Wendif-labels -Wexpansion-to-defined
> -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value
> -Wno-psabi -fstack-protector-strong -fPIC -DSTRUCT_IOVEC_DEFINED
> -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
> -DNCURSES_WIDECHAR -MD -MQ libcommon.fa.p/hw_intc_i8259.c.o -MF
> libcommon.fa.p/hw_intc_i8259.c.o.d -o libcommon.fa.p/hw_intc_i8259.c.o -c
> ../hw/intc/i8259.c
> ../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;
> | ~~~~^~~~~~~~~~
> cc1: all warnings being treated as errors
>
> Due to other compile warnings I find this hard to bisect. Has anyone seen
> this as well?
I've never seen this warnings so far... which compiler version is this?
Looking at the code, it seems to be a false positive to me.
Thomas
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 15:14 compile warning in i8259.c Christian Borntraeger
2021-03-15 15:42 ` Thomas Huth
@ 2021-03-15 15:44 ` Christian Borntraeger
2021-03-15 15:55 ` Philippe Mathieu-Daudé
2021-03-15 16:20 ` Thomas Huth
1 sibling, 2 replies; 12+ messages in thread
From: Christian Borntraeger @ 2021-03-15 15:44 UTC (permalink / raw)
To: qemu-devel, qemu-s390x; +Cc: Paolo Bonzini, Michael S. Tsirkin
On 15.03.21 16:14, Christian Borntraeger wrote:
> For some time now I do see the following, when I compile x86-softmmu on s390:
>
> FAILED: libcommon.fa.p/hw_intc_i8259.c.o
> cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/capstone -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/libusb-1.0 -I/usr/include/vte-2.91 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -I/usr/include/virgl -I/usr/include/p11-kit-1 -I/usr/include/SDL2 -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/slirp -fdiagnostics-color=auto -pipe -Wall -Winvalid-pch -Werror -std=gnu99 -O2 -g -isystem /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers -iquote . -iquote /home/cborntra/REPOS/qemu -iquote
> /home/cborntra/REPOS/qemu/include -iquote /home/cborntra/REPOS/qemu/disas/libvixl -iquote /home/cborntra/REPOS/qemu/tcg/s390 -iquote /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIC -DSTRUCT_IOVEC_DEFINED -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ libcommon.fa.p/hw_intc_i8259.c.o -MF libcommon.fa.p/hw_intc_i8259.c.o.d -o libcommon.fa.p/hw_intc_i8259.c.o -c ../hw/intc/i8259.c
> ../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;
> | ~~~~^~~~~~~~~~
> cc1: all warnings being treated as errors
>
>
> Due to other compile warnings I find this hard to bisect. Has anyone seen this as well?
cc Michael, Paolo,
Something like
diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
index 344fd04db14d..7335b7a06a67 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 = 0, intno;
irq = pic_get_irq(s);
if (irq >= 0) {
would do the trick. Let me know if I should do a proper patch or if you want to have things solved differently.
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 15:42 ` Thomas Huth
@ 2021-03-15 15:46 ` Christian Borntraeger
2021-03-15 15:50 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2021-03-15 15:46 UTC (permalink / raw)
To: Thomas Huth, qemu-devel, qemu-s390x, Paolo Bonzini,
Michael S Tsirkin
On 15.03.21 16:42, Thomas Huth wrote:
> On 15/03/2021 16.14, Christian Borntraeger wrote:
>> For some time now I do see the following, when I compile x86-softmmu on s390:
>>
>> FAILED: libcommon.fa.p/hw_intc_i8259.c.o
>> cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/capstone -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/libusb-1.0 -I/usr/include/vte-2.91 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -I/usr/include/virgl -I/usr/include/p11-kit-1 -I/usr/include/SDL2 -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/slirp -fdiagnostics-color=auto -pipe -Wall -Winvalid-pch -Werror -std=gnu99 -O2 -g -isystem /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers -iquote . -iquote /home/cborntra/REPOS/qemu -iquote
>> /home/cborntra/REPOS/qemu/include -iquote /home/cborntra/REPOS/qemu/disas/libvixl -iquote /home/cborntra/REPOS/qemu/tcg/s390 -iquote /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIC -DSTRUCT_IOVEC_DEFINED -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ libcommon.fa.p/hw_intc_i8259.c.o -MF libcommon.fa.p/hw_intc_i8259.c.o.d -o libcommon.fa.p/hw_intc_i8259.c.o -c ../hw/intc/i8259.c
>> ../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;
>> | ~~~~^~~~~~~~~~
>> cc1: all warnings being treated as errors
>>
>> Due to other compile warnings I find this hard to bisect. Has anyone seen this as well?
>
> I've never seen this warnings so far... which compiler version is this? Looking at the code, it seems to be a false positive to me.
Its the fedora33 gcc.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 15:42 ` Thomas Huth
2021-03-15 15:46 ` Christian Borntraeger
@ 2021-03-15 15:50 ` Philippe Mathieu-Daudé
2021-03-15 15:58 ` Thomas Huth
1 sibling, 1 reply; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-03-15 15:50 UTC (permalink / raw)
To: Thomas Huth, Christian Borntraeger, qemu-devel, qemu-s390x
On 3/15/21 4:42 PM, Thomas Huth wrote:
> On 15/03/2021 16.14, Christian Borntraeger wrote:
>> For some time now I do see the following, when I compile x86-softmmu
>> on s390:
>>
>> FAILED: libcommon.fa.p/hw_intc_i8259.c.o
>> cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader
>> -I/usr/include/capstone -I/usr/include/glib-2.0
>> -I/usr/lib64/glib-2.0/include -I/usr/include/libmount
>> -I/usr/include/blkid -I/usr/include/gio-unix-2.0
>> -I/usr/include/libusb-1.0 -I/usr/include/vte-2.91
>> -I/usr/include/pango-1.0 -I/usr/include/harfbuzz
>> -I/usr/include/freetype2 -I/usr/include/libpng16
>> -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo
>> -I/usr/include/pixman-1 -I/usr/include/gtk-3.0
>> -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0
>> -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0
>> -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0
>> -I/usr/include/virgl -I/usr/include/p11-kit-1 -I/usr/include/SDL2
>> -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4
>> -I/usr/include/slirp -fdiagnostics-color=auto -pipe -Wall
>> -Winvalid-pch -Werror -std=gnu99 -O2 -g -isystem
>> /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers -iquote
>> . -iquote /home/cborntra/REPOS/qemu -iquote
>> /home/cborntra/REPOS/qemu/include -iquote
>> /home/cborntra/REPOS/qemu/disas/libvixl -iquote
>> /home/cborntra/REPOS/qemu/tcg/s390 -iquote
>> /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE
>> -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
>> -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
>> -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common
>> -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits
>> -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers
>> -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
>> -Wimplicit-fallthrough=2 -Wno-missing-include-dirs
>> -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIC
>> -DSTRUCT_IOVEC_DEFINED -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE
>> -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ
>> libcommon.fa.p/hw_intc_i8259.c.o -MF
>> libcommon.fa.p/hw_intc_i8259.c.o.d -o libcommon.fa.p/hw_intc_i8259.c.o
>> -c ../hw/intc/i8259.c
>> ../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;
>> | ~~~~^~~~~~~~~~
>> cc1: all warnings being treated as errors
>>
>> Due to other compile warnings I find this hard to bisect. Has anyone
>> seen this as well?
>
> I've never seen this warnings so far... which compiler version is this?
> Looking at the code, it seems to be a false positive to me.
https://www.mail-archive.com/qemu-devel@nongnu.org/msg599522.html
=)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 15:44 ` Christian Borntraeger
@ 2021-03-15 15:55 ` Philippe Mathieu-Daudé
2021-03-15 16:43 ` Paolo Bonzini
2021-03-15 16:20 ` Thomas Huth
1 sibling, 1 reply; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-03-15 15:55 UTC (permalink / raw)
To: Christian Borntraeger, qemu-devel, qemu-s390x
Cc: Paolo Bonzini, Michael S. Tsirkin
On 3/15/21 4:44 PM, Christian Borntraeger wrote:
> On 15.03.21 16:14, Christian Borntraeger wrote:
>> For some time now I do see the following, when I compile x86-softmmu
>> on s390:
>>
>> FAILED: libcommon.fa.p/hw_intc_i8259.c.o
>> cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader
>> -I/usr/include/capstone -I/usr/include/glib-2.0
>> -I/usr/lib64/glib-2.0/include -I/usr/include/libmount
>> -I/usr/include/blkid -I/usr/include/gio-unix-2.0
>> -I/usr/include/libusb-1.0 -I/usr/include/vte-2.91
>> -I/usr/include/pango-1.0 -I/usr/include/harfbuzz
>> -I/usr/include/freetype2 -I/usr/include/libpng16
>> -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo
>> -I/usr/include/pixman-1 -I/usr/include/gtk-3.0
>> -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0
>> -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0
>> -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0
>> -I/usr/include/virgl -I/usr/include/p11-kit-1 -I/usr/include/SDL2
>> -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4
>> -I/usr/include/slirp -fdiagnostics-color=auto -pipe -Wall
>> -Winvalid-pch -Werror -std=gnu99 -O2 -g -isystem
>> /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers -iquote
>> . -iquote /home/cborntra/REPOS/qemu -iquote
>> /home/cborntra/REPOS/qemu/include -iquote
>> /home/cborntra/REPOS/qemu/disas/libvixl -iquote
>> /home/cborntra/REPOS/qemu/tcg/s390 -iquote
>> /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE
>> -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
>> -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
>> -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common
>> -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits
>> -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers
>> -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
>> -Wimplicit-fallthrough=2 -Wno-missing-include-dirs
>> -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIC
>> -DSTRUCT_IOVEC_DEFINED -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE
>> -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ
>> libcommon.fa.p/hw_intc_i8259.c.o -MF
>> libcommon.fa.p/hw_intc_i8259.c.o.d -o libcommon.fa.p/hw_intc_i8259.c.o
>> -c ../hw/intc/i8259.c
>> ../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;
>> | ~~~~^~~~~~~~~~
>> cc1: all warnings being treated as errors
>>
>>
>> Due to other compile warnings I find this hard to bisect. Has anyone
>> seen this as well?
>
> cc Michael, Paolo,
>
> Something like
>
> diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
> index 344fd04db14d..7335b7a06a67 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 = 0, intno;
>
> irq = pic_get_irq(s);
> if (irq >= 0) {
>
>
> would do the trick. Let me know if I should do a proper patch or if you
> want to have things solved differently.
Since you ask, I'd love to have things solved differently...
One PIC has 8 IRQs, so we should model 2 cascaded PICs as 2 cascaded
QOM PICs. But this code is so old and heavily used that my desire
is unlikely to be realized. And your patch is simpler :>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 15:50 ` Philippe Mathieu-Daudé
@ 2021-03-15 15:58 ` Thomas Huth
2021-03-15 16:15 ` Christian Borntraeger
0 siblings, 1 reply; 12+ messages in thread
From: Thomas Huth @ 2021-03-15 15:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Christian Borntraeger, qemu-devel,
qemu-s390x
On 15/03/2021 16.50, Philippe Mathieu-Daudé wrote:
> On 3/15/21 4:42 PM, Thomas Huth wrote:
>> On 15/03/2021 16.14, Christian Borntraeger wrote:
>>> For some time now I do see the following, when I compile x86-softmmu
>>> on s390:
>>>
>>> FAILED: libcommon.fa.p/hw_intc_i8259.c.o
>>> cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader
>>> -I/usr/include/capstone -I/usr/include/glib-2.0
>>> -I/usr/lib64/glib-2.0/include -I/usr/include/libmount
>>> -I/usr/include/blkid -I/usr/include/gio-unix-2.0
>>> -I/usr/include/libusb-1.0 -I/usr/include/vte-2.91
>>> -I/usr/include/pango-1.0 -I/usr/include/harfbuzz
>>> -I/usr/include/freetype2 -I/usr/include/libpng16
>>> -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo
>>> -I/usr/include/pixman-1 -I/usr/include/gtk-3.0
>>> -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0
>>> -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0
>>> -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0
>>> -I/usr/include/virgl -I/usr/include/p11-kit-1 -I/usr/include/SDL2
>>> -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4
>>> -I/usr/include/slirp -fdiagnostics-color=auto -pipe -Wall
>>> -Winvalid-pch -Werror -std=gnu99 -O2 -g -isystem
>>> /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers -iquote
>>> . -iquote /home/cborntra/REPOS/qemu -iquote
>>> /home/cborntra/REPOS/qemu/include -iquote
>>> /home/cborntra/REPOS/qemu/disas/libvixl -iquote
>>> /home/cborntra/REPOS/qemu/tcg/s390 -iquote
>>> /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE
>>> -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
>>> -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
>>> -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common
>>> -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits
>>> -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers
>>> -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
>>> -Wimplicit-fallthrough=2 -Wno-missing-include-dirs
>>> -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIC
>>> -DSTRUCT_IOVEC_DEFINED -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE
>>> -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ
>>> libcommon.fa.p/hw_intc_i8259.c.o -MF
>>> libcommon.fa.p/hw_intc_i8259.c.o.d -o libcommon.fa.p/hw_intc_i8259.c.o
>>> -c ../hw/intc/i8259.c
>>> ../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;
>>> | ~~~~^~~~~~~~~~
>>> cc1: all warnings being treated as errors
>>>
>>> Due to other compile warnings I find this hard to bisect. Has anyone
>>> seen this as well?
>>
>> I've never seen this warnings so far... which compiler version is this?
>> Looking at the code, it seems to be a false positive to me.
>
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg599522.html
Oh, well, I completely forgot about that one ... but that was with -O3 ...
interesting that it now occurs with -O2, too!
But even after staring at the code for a while, I cannot see how irq2 may
not be initialized here ... so this really rather sounds like a compiler bug
to me... anyway, we could simply silence it by pre-initializing the variable
to -1 or so?
Thomas
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 15:58 ` Thomas Huth
@ 2021-03-15 16:15 ` Christian Borntraeger
0 siblings, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2021-03-15 16:15 UTC (permalink / raw)
To: Thomas Huth, Philippe Mathieu-Daudé, qemu-devel, qemu-s390x
On 15.03.21 16:58, Thomas Huth wrote:
> On 15/03/2021 16.50, Philippe Mathieu-Daudé wrote:
>> On 3/15/21 4:42 PM, Thomas Huth wrote:
>>> On 15/03/2021 16.14, Christian Borntraeger wrote:
>>>> For some time now I do see the following, when I compile x86-softmmu
>>>> on s390:
>>>>
>>>> FAILED: libcommon.fa.p/hw_intc_i8259.c.o
>>>> cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader
>>>> -I/usr/include/capstone -I/usr/include/glib-2.0
>>>> -I/usr/lib64/glib-2.0/include -I/usr/include/libmount
>>>> -I/usr/include/blkid -I/usr/include/gio-unix-2.0
>>>> -I/usr/include/libusb-1.0 -I/usr/include/vte-2.91
>>>> -I/usr/include/pango-1.0 -I/usr/include/harfbuzz
>>>> -I/usr/include/freetype2 -I/usr/include/libpng16
>>>> -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo
>>>> -I/usr/include/pixman-1 -I/usr/include/gtk-3.0
>>>> -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0
>>>> -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0
>>>> -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0
>>>> -I/usr/include/virgl -I/usr/include/p11-kit-1 -I/usr/include/SDL2
>>>> -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4
>>>> -I/usr/include/slirp -fdiagnostics-color=auto -pipe -Wall
>>>> -Winvalid-pch -Werror -std=gnu99 -O2 -g -isystem
>>>> /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers -iquote
>>>> . -iquote /home/cborntra/REPOS/qemu -iquote
>>>> /home/cborntra/REPOS/qemu/include -iquote
>>>> /home/cborntra/REPOS/qemu/disas/libvixl -iquote
>>>> /home/cborntra/REPOS/qemu/tcg/s390 -iquote
>>>> /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE
>>>> -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
>>>> -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
>>>> -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common
>>>> -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits
>>>> -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers
>>>> -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
>>>> -Wimplicit-fallthrough=2 -Wno-missing-include-dirs
>>>> -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIC
>>>> -DSTRUCT_IOVEC_DEFINED -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE
>>>> -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ
>>>> libcommon.fa.p/hw_intc_i8259.c.o -MF
>>>> libcommon.fa.p/hw_intc_i8259.c.o.d -o libcommon.fa.p/hw_intc_i8259.c.o
>>>> -c ../hw/intc/i8259.c
>>>> ../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;
>>>> | ~~~~^~~~~~~~~~
>>>> cc1: all warnings being treated as errors
>>>>
>>>> Due to other compile warnings I find this hard to bisect. Has anyone
>>>> seen this as well?
>>>
>>> I've never seen this warnings so far... which compiler version is this?
>>> Looking at the code, it seems to be a false positive to me.
>>
>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg599522.html
>
> Oh, well, I completely forgot about that one ... but that was with -O3 ... interesting that it now occurs with -O2, too!
>
> But even after staring at the code for a while, I cannot see how irq2 may not be initialized here ... so this really rather sounds like a compiler bug to me...
Its not a bug, its part of the nature for "may be" warnings. The compiler cannot figure out.
anyway, we could simply silence it by pre-initializing the variable to -1 or so?
I can certainly spin up a patch with -1.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 15:44 ` Christian Borntraeger
2021-03-15 15:55 ` Philippe Mathieu-Daudé
@ 2021-03-15 16:20 ` Thomas Huth
2021-03-15 16:27 ` Richard Henderson
2021-03-15 16:27 ` Christian Borntraeger
1 sibling, 2 replies; 12+ messages in thread
From: Thomas Huth @ 2021-03-15 16:20 UTC (permalink / raw)
To: Christian Borntraeger, qemu-devel, qemu-s390x
Cc: Paolo Bonzini, Michael S. Tsirkin
On 15/03/2021 16.44, Christian Borntraeger wrote:
> On 15.03.21 16:14, Christian Borntraeger wrote:
>> For some time now I do see the following, when I compile x86-softmmu on s390:
>>
>> FAILED: libcommon.fa.p/hw_intc_i8259.c.o
>> cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader
>> -I/usr/include/capstone -I/usr/include/glib-2.0
>> -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid
>> -I/usr/include/gio-unix-2.0 -I/usr/include/libusb-1.0
>> -I/usr/include/vte-2.91 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz
>> -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi
>> -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1
>> -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0
>> -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0
>> -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include
>> -I/usr/include/at-spi-2.0 -I/usr/include/virgl -I/usr/include/p11-kit-1
>> -I/usr/include/SDL2 -I/usr/include/cacard -I/usr/include/nss3
>> -I/usr/include/nspr4 -I/usr/include/slirp -fdiagnostics-color=auto -pipe
>> -Wall -Winvalid-pch -Werror -std=gnu99 -O2 -g -isystem
>> /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers -iquote .
>> -iquote /home/cborntra/REPOS/qemu -iquote
>> /home/cborntra/REPOS/qemu/include -iquote
>> /home/cborntra/REPOS/qemu/disas/libvixl -iquote
>> /home/cborntra/REPOS/qemu/tcg/s390 -iquote
>> /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE
>> -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
>> -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
>> -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common
>> -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits
>> -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers
>> -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
>> -Wimplicit-fallthrough=2 -Wno-missing-include-dirs
>> -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIC
>> -DSTRUCT_IOVEC_DEFINED -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE
>> -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ
>> libcommon.fa.p/hw_intc_i8259.c.o -MF libcommon.fa.p/hw_intc_i8259.c.o.d -o
>> libcommon.fa.p/hw_intc_i8259.c.o -c ../hw/intc/i8259.c
>> ../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;
>> | ~~~~^~~~~~~~~~
>> cc1: all warnings being treated as errors
>>
>>
>> Due to other compile warnings I find this hard to bisect. Has anyone seen
>> this as well?
>
> cc Michael, Paolo,
>
> Something like
>
> diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
> index 344fd04db14d..7335b7a06a67 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 = 0, intno;
>
> irq = pic_get_irq(s);
> if (irq >= 0) {
>
>
> would do the trick. Let me know if I should do a proper patch or if you want
> to have things solved differently.
Alternate idea, merge the two "irq == 2" blocks:
diff a/hw/intc/i8259.c b/hw/intc/i8259.c
--- a/hw/intc/i8259.c
+++ b/hw/intc/i8259.c
@@ -179,19 +179,19 @@ int pic_read_irq(DeviceState *d)
int irq, irq2, intno;
irq = pic_get_irq(s);
- if (irq >= 0) {
- if (irq == 2) {
- irq2 = pic_get_irq(slave_pic);
- if (irq2 >= 0) {
- pic_intack(slave_pic, irq2);
- } else {
- /* spurious IRQ on slave controller */
- irq2 = 7;
- }
- intno = slave_pic->irq_base + irq2;
+ if (irq == 2) {
+ irq2 = pic_get_irq(slave_pic);
+ if (irq2 >= 0) {
+ pic_intack(slave_pic, irq2);
} else {
- intno = s->irq_base + irq;
+ /* spurious IRQ on slave controller */
+ irq2 = 7;
}
+ intno = slave_pic->irq_base + irq2;
+ pic_intack(s, irq);
+ irq = irq2 + 8;
+ } else if (irq >= 0) {
+ intno = s->irq_base + irq;
pic_intack(s, irq);
} else {
/* spurious IRQ on host controller */
@@ -199,10 +199,6 @@ int pic_read_irq(DeviceState *d)
intno = s->irq_base + irq;
}
- if (irq == 2) {
- irq = irq2 + 8;
- }
-
#ifdef DEBUG_IRQ_LATENCY
printf("IRQ%d latency=%0.3fus\n",
irq,
It's a bigger patch, but the code is IMHO easier to read afterwards (less
indentation).
Thomas
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 16:20 ` Thomas Huth
@ 2021-03-15 16:27 ` Richard Henderson
2021-03-15 16:27 ` Christian Borntraeger
1 sibling, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2021-03-15 16:27 UTC (permalink / raw)
To: Thomas Huth, Christian Borntraeger, qemu-devel, qemu-s390x
Cc: Paolo Bonzini, Michael S. Tsirkin
On 3/15/21 10:20 AM, Thomas Huth wrote:
> + if (irq == 2) {
> + irq2 = pic_get_irq(slave_pic);
This looks better. You should also be able to pull in the declaration to
int irq2 = pic_get_irq(slave_pic);
here.
r~
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 16:20 ` Thomas Huth
2021-03-15 16:27 ` Richard Henderson
@ 2021-03-15 16:27 ` Christian Borntraeger
1 sibling, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2021-03-15 16:27 UTC (permalink / raw)
To: Thomas Huth, qemu-devel, qemu-s390x; +Cc: Paolo Bonzini, Michael S. Tsirkin
On 15.03.21 17:20, Thomas Huth wrote:
> On 15/03/2021 16.44, Christian Borntraeger wrote:
>> On 15.03.21 16:14, Christian Borntraeger wrote:
>>> For some time now I do see the following, when I compile x86-softmmu on s390:
>>>
>>> FAILED: libcommon.fa.p/hw_intc_i8259.c.o
>>> cc -Ilibcommon.fa.p -I. -I.. -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/capstone -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/libusb-1.0 -I/usr/include/vte-2.91 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -I/usr/include/virgl -I/usr/include/p11-kit-1 -I/usr/include/SDL2 -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/slirp -fdiagnostics-color=auto -pipe -Wall -Winvalid-pch -Werror -std=gnu99 -O2 -g -isystem /home/cborntra/REPOS/qemu/linux-headers -isystem linux-headers -iquote . -iquote /home/cborntra/REPOS/qemu
>>> -iquote /home/cborntra/REPOS/qemu/include -iquote /home/cborntra/REPOS/qemu/disas/libvixl -iquote /home/cborntra/REPOS/qemu/tcg/s390 -iquote /home/cborntra/REPOS/qemu/accel/tcg -pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIC -DSTRUCT_IOVEC_DEFINED -D_REENTRANT -Wno-undef -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -MD -MQ libcommon.fa.p/hw_intc_i8259.c.o -MF libcommon.fa.p/hw_intc_i8259.c.o.d -o libcommon.fa.p/hw_intc_i8259.c.o -c ../hw/intc/i8259.c
>>> ../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;
>>> | ~~~~^~~~~~~~~~
>>> cc1: all warnings being treated as errors
>>>
>>>
>>> Due to other compile warnings I find this hard to bisect. Has anyone seen this as well?
>>
>> cc Michael, Paolo,
>>
>> Something like
>>
>> diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
>> index 344fd04db14d..7335b7a06a67 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 = 0, intno;
>>
>> irq = pic_get_irq(s);
>> if (irq >= 0) {
>>
>>
>> would do the trick. Let me know if I should do a proper patch or if you want to have things solved differently.
>
> Alternate idea, merge the two "irq == 2" blocks:
>
> diff a/hw/intc/i8259.c b/hw/intc/i8259.c
> --- a/hw/intc/i8259.c
> +++ b/hw/intc/i8259.c
> @@ -179,19 +179,19 @@ int pic_read_irq(DeviceState *d)
> int irq, irq2, intno;
>
> irq = pic_get_irq(s);
> - if (irq >= 0) {
> - if (irq == 2) {
> - irq2 = pic_get_irq(slave_pic);
> - if (irq2 >= 0) {
> - pic_intack(slave_pic, irq2);
> - } else {
> - /* spurious IRQ on slave controller */
> - irq2 = 7;
> - }
> - intno = slave_pic->irq_base + irq2;
> + if (irq == 2) {
> + irq2 = pic_get_irq(slave_pic);
> + if (irq2 >= 0) {
> + pic_intack(slave_pic, irq2);
> } else {
> - intno = s->irq_base + irq;
> + /* spurious IRQ on slave controller */
> + irq2 = 7;
> }
> + intno = slave_pic->irq_base + irq2;
> + pic_intack(s, irq);
> + irq = irq2 + 8;
> + } else if (irq >= 0) {
> + intno = s->irq_base + irq;
> pic_intack(s, irq);
> } else {
> /* spurious IRQ on host controller */
> @@ -199,10 +199,6 @@ int pic_read_irq(DeviceState *d)
> intno = s->irq_base + irq;
> }
>
> - if (irq == 2) {
> - irq = irq2 + 8;
> - }
> -
> #ifdef DEBUG_IRQ_LATENCY
> printf("IRQ%d latency=%0.3fus\n",
> irq,
>
> It's a bigger patch, but the code is IMHO easier to read afterwards (less indentation).
I would defer such a change to someone more familiar with x86.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: compile warning in i8259.c
2021-03-15 15:55 ` Philippe Mathieu-Daudé
@ 2021-03-15 16:43 ` Paolo Bonzini
0 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2021-03-15 16:43 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Christian Borntraeger, qemu-devel,
qemu-s390x
Cc: Michael S. Tsirkin
On 15/03/21 16:55, Philippe Mathieu-Daudé wrote:
> Since you ask, I'd love to have things solved differently...
> One PIC has 8 IRQs, so we should model 2 cascaded PICs as 2 cascaded
> QOM PICs. But this code is so old and heavily used that my desire
> is unlikely to be realized. And your patch is simpler :>
They are modeled like that, see i8259_init. Perhaps you mean that
pic_read_irq should call itself recursively on the slave PIC if irq == 2
&& s->master?
Paolo
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-03-15 16:48 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-15 15:14 compile warning in i8259.c Christian Borntraeger
2021-03-15 15:42 ` Thomas Huth
2021-03-15 15:46 ` Christian Borntraeger
2021-03-15 15:50 ` Philippe Mathieu-Daudé
2021-03-15 15:58 ` Thomas Huth
2021-03-15 16:15 ` Christian Borntraeger
2021-03-15 15:44 ` Christian Borntraeger
2021-03-15 15:55 ` Philippe Mathieu-Daudé
2021-03-15 16:43 ` Paolo Bonzini
2021-03-15 16:20 ` Thomas Huth
2021-03-15 16:27 ` Richard Henderson
2021-03-15 16:27 ` Christian Borntraeger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).