or1k: Fix compilation hiccup
PATCH 1/1 or1k: Fix compilation hiccup
On my Fedora 32 machine, gcc 10.1.1 at -O2 (the default for a bare './configure') has a false-positive complaint:
CC or1k-softmmu/hw/openrisc/openrisc_sim.o/home/eblake/qemu/hw/openrisc/openrisc_sim.c: In function ‘openrisc_sim_init’:/home/eblake/qemu/hw/openrisc/openrisc_sim.c:87:42: error: ‘cpu_irqs[0]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
87 | sysbus_connect_irq(s, i, cpu_irqs[i][irq_pin]);
| ~~~~~~~~^~~Initializing both pointers of cpu_irqs[] to NULL is sufficient to shut up the compiler, even though they are definitely assigned in openrisc_sim_init() prior to the inlined call to openrisc_sim_ompic_init() containing the line in question.
--- hw/openrisc/openrisc_sim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/openrisc/openrisc_sim.c +1 -1
@@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;OpenRISCCPU *cpu =NULL ;MemoryRegion *ram; -qemu_irq *cpu_irqs[2 ]; +qemu_irq *cpu_irqs[2 ] = {};qemu_irq serial_irq;int n;unsigned int smp_cpus = machine->smp.cpus;
Signature · 1 line
2.26.2
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Subject: [PATCH] or1k: Fix compilation hiccup
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Switched to a new branch 'test'
d96d2fb or1k: Fix compilation hiccup
=== OUTPUT BEGIN ===
ERROR: spaces required around that '*' (ctx:WxV)
#33: FILE: hw/openrisc/openrisc_sim.c:132:
+ qemu_irq *cpu_irqs[2] = {};
^total: 1 errors, 0 warnings, 8 lines checked
Commit d96d2fbbc5db (or1k: Fix compilation hiccup) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 13 lines · On 5/26/20 6:21 PM, [email protected] wrote:
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
=== OUTPUT BEGIN ===
ERROR: spaces required around that '*' (ctx:WxV)
#33: FILE:hw/openrisc/openrisc_sim.c:132:
Quoted 8 lines
+ qemu_irq *cpu_irqs[2] = {}; ^total: 1 errors, 0 warnings, 8 lines checked
Commit
d96d2fbbc5db(or1k: Fix compilation hiccup) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH inMAINTAINERS.
False positive, due to 'qemu_irq' not following the normal naming conventions for typedefs.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Quoted 25 lines · Eric Blake
On my Fedora 32 machine, gcc 10.1.1 at -O2 (the default for a bare './configure') has a false-positive complaint:
CC
or1k-softmmu/hw/openrisc/openrisc_sim.o/home/eblake/qemu/hw/openrisc/openrisc_sim.c: In function ‘openrisc_sim_init’:/home/eblake/qemu/hw/openrisc/openrisc_sim.c:87:42: error: ‘cpu_irqs[0]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]87 | sysbus_connect_irq(s, i, cpu_irqs[i][irq_pin]); | ~~~~~~~~^~~Initializing both pointers of cpu_irqs[] to NULL is sufficient to shut up the compiler, even though they are definitely assigned in
openrisc_sim_init()prior to the inlined call toopenrisc_sim_ompic_init()containing the line in question.Signed-off-by Eric Blake <[email protected]>--- hw/openrisc/openrisc_sim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/openrisc/openrisc_sim.c +0
-0
hw/openrisc/openrisc_sim.c static void openrisc_sim_init(MachineState *machine) · line 135
Quoted 8 lines
hw/openrisc/openrisc_sim.c +1
-1@@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;OpenRISCCPU *cpu =NULL ;MemoryRegion *ram; -qemu_irq *cpu_irqs[2 ]; +qemu_irq *cpu_irqs[2 ] = {};qemu_irq serial_irq;int n;unsigned int smp_cpus = machine->smp.cpus;
Quoted 24 lines · Eric Blake
On my Fedora 32 machine, gcc 10.1.1 at -O2 (the default for a bare './configure') has a false-positive complaint:
CC
or1k-softmmu/hw/openrisc/openrisc_sim.o/home/eblake/qemu/hw/openrisc/openrisc_sim.c: In function ‘openrisc_sim_init’:/home/eblake/qemu/hw/openrisc/openrisc_sim.c:87:42: error: ‘cpu_irqs[0]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]87 | sysbus_connect_irq(s, i, cpu_irqs[i][irq_pin]); | ~~~~~~~~^~~Initializing both pointers of cpu_irqs[] to NULL is sufficient to shut up the compiler, even though they are definitely assigned in
openrisc_sim_init()prior to the inlined call toopenrisc_sim_ompic_init()containing the line in question.Signed-off-by Eric Blake <[email protected]>--- hw/openrisc/openrisc_sim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/openrisc/openrisc_sim.c +0
-0
hw/openrisc/openrisc_sim.c static void openrisc_sim_init(MachineState *machine) · line 132
Quoted 5 lines
hw/openrisc/openrisc_sim.c +1
-1@@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;OpenRISCCPU *cpu =NULL ;MemoryRegion *ram; -qemu_irq *cpu_irqs[2 ]; +qemu_irq *cpu_irqs[2 ] = {};
Ah I now remembered why this warning sound familiar:
https://bugs.launchpad.net/qemu/+bug/1874073
Peter suggested a different fix, I tested it, and was expecting Martin Liska to post an updated patch.
Quoted 4 lines
hw/openrisc/openrisc_sim.c +0
-0qemu_irq serial_irq;int n;unsigned int smp_cpus = machine->smp.cpus;
On 2020-05-26 at 20:51 CEST, Eric Blake wrote...
Quoted 24 lines
On my Fedora 32 machine, gcc 10.1.1 at -O2 (the default for a bare './configure') has a false-positive complaint:
CC
or1k-softmmu/hw/openrisc/openrisc_sim.o/home/eblake/qemu/hw/openrisc/openrisc_sim.c: In function ‘openrisc_sim_init’:/home/eblake/qemu/hw/openrisc/openrisc_sim.c:87:42: error: ‘cpu_irqs[0]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]87 | sysbus_connect_irq(s, i, cpu_irqs[i][irq_pin]); | ~~~~~~~~^~~Initializing both pointers of cpu_irqs[] to NULL is sufficient to shut up the compiler, even though they are definitely assigned in
openrisc_sim_init()prior to the inlined call toopenrisc_sim_ompic_init()containing the line in question.Signed-off-by Eric Blake <[email protected]>--- hw/openrisc/openrisc_sim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/openrisc/openrisc_sim.c +0
-0
hw/openrisc/openrisc_sim.c static void openrisc_sim_init(MachineState *machine) · line 132
Quoted 5 lines
hw/openrisc/openrisc_sim.c +1
-1@@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;OpenRISCCPU *cpu =NULL ;MemoryRegion *ram; -qemu_irq *cpu_irqs[2 ]; +qemu_irq *cpu_irqs[2 ] = {};
Why is the value [2] correct here? The loop that initializes loops over machine->smp.cpus. Is it always less than 2 on this machine?
hw/openrisc/openrisc_sim.c static void openrisc_sim_init(MachineState *machine) · line 135
Quoted 3 lines
hw/openrisc/openrisc_sim.c +0
-0qemu_irq serial_irq;int n;unsigned int smp_cpus = machine->smp.cpus;
--
Cheers,
Christophe de Dinechin (IRC c3d)
Quoted 14 lines · Christophe de Dinechin
On 2020-05-26 at 20:51 CEST, Eric Blake wrote...
hw/openrisc/openrisc_sim.c static void openrisc_sim_init(MachineState *machine) · line 132
Quoted 10 lines
hw/openrisc/openrisc_sim.c +1
-1@@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;OpenRISCCPU *cpu =NULL ;MemoryRegion *ram; -qemu_irq *cpu_irqs[2 ]; +qemu_irq *cpu_irqs[2 ] = {};Why is the value [2] correct here? The loop that initializes loops over
machine->smp.cpus. Is it always less than 2 on this machine?
Yes: openrisc_sim_machine_init() sets mc->max_cpus = 2. My suggestion of adding an assert() is essentially telling the compiler that indeed smp_cpus must always be in the range [1,2], which we can tell but it can't.
thanks
-- PMM
Quoted 17 lines · Peter Maydell
Quoted 14 lines · Christophe de Dinechin
On 2020-05-26 at 20:51 CEST, Eric Blake wrote...
hw/openrisc/openrisc_sim.c static void openrisc_sim_init(MachineState *machine) · line 132
Quoted 10 lines
hw/openrisc/openrisc_sim.c +1
-1@@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;OpenRISCCPU *cpu =NULL ;MemoryRegion *ram; -qemu_irq *cpu_irqs[2 ]; +qemu_irq *cpu_irqs[2 ] = {};Why is the value [2] correct here? The loop that initializes loops over
machine->smp.cpus. Is it always less than 2 on this machine?
Quoted 4 lines
Yes:
openrisc_sim_machine_init()setsmc->max_cpus= 2. My suggestion of adding anassert()is essentially telling the compiler that indeedsmp_cpusmust always be in the range [1,2], which we can tell but it can't.
Do we have a proper patch for this on the list?
Quoted 19 lines · Markus Armbruster
Quoted 17 lines · Peter Maydell
Quoted 14 lines · Christophe de Dinechin
On 2020-05-26 at 20:51 CEST, Eric Blake wrote...
hw/openrisc/openrisc_sim.c static void openrisc_sim_init(MachineState *machine) · line 132
Quoted 10 lines
hw/openrisc/openrisc_sim.c +1
-1@@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;OpenRISCCPU *cpu =NULL ;MemoryRegion *ram; -qemu_irq *cpu_irqs[2 ]; +qemu_irq *cpu_irqs[2 ] = {};Why is the value [2] correct here? The loop that initializes loops over
machine->smp.cpus. Is it always less than 2 on this machine?
Quoted 6 lines
Quoted 4 lines
Yes:
openrisc_sim_machine_init()setsmc->max_cpus= 2. My suggestion of adding anassert()is essentially telling the compiler that indeedsmp_cpusmust always be in the range [1,2], which we can tell but it can't.Do we have a proper patch for this on the list?
Apparently not.
Philippe did try Peter's suggestion, found it works, but then posted it only to Launchpad. Philippe, please post to the list, so we can finally get this fixed.
Quoted 26 lines · Markus Armbruster
Quoted 24 lines · Markus Armbruster
Quoted 21 lines · Peter Maydell
Quoted 14 lines · Christophe de Dinechin
On 2020-05-26 at 20:51 CEST, Eric Blake wrote...
hw/openrisc/openrisc_sim.c static void openrisc_sim_init(MachineState *machine) · line 132
Quoted 10 lines
hw/openrisc/openrisc_sim.c +1
-1@@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;OpenRISCCPU *cpu =NULL ;MemoryRegion *ram; -qemu_irq *cpu_irqs[2 ]; +qemu_irq *cpu_irqs[2 ] = {};Why is the value [2] correct here? The loop that initializes loops over
machine->smp.cpus. Is it always less than 2 on this machine?Yes:
openrisc_sim_machine_init()setsmc->max_cpus= 2. My suggestion of adding anassert()is essentially telling the compiler that indeedsmp_cpusmust always be in the range [1,2], which we can tell but it can't.
Quoted 7 lines
Quoted 1 line
Do we have a proper patch for this on the list?
Apparently not.
Philippe did try Peter's suggestion, found it works, but then posted it only to Launchpad. Philippe, please post to the list, so we can finally get this fixed.
Sorry since it was Eric finding, I didn't understood I had to post it. Will do.
Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Markus Armbruster
Quoted 25 lines · Markus Armbruster
Quoted 17 lines · Peter Maydell
Quoted 14 lines · Christophe de Dinechin
On 2020-05-26 at 20:51 CEST, Eric Blake wrote...
hw/openrisc/openrisc_sim.c static void openrisc_sim_init(MachineState *machine) · line 132
Quoted 10 lines
hw/openrisc/openrisc_sim.c +1
-1@@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;OpenRISCCPU *cpu =NULL ;MemoryRegion *ram; -qemu_irq *cpu_irqs[2 ]; +qemu_irq *cpu_irqs[2 ] = {};Why is the value [2] correct here? The loop that initializes loops over
machine->smp.cpus. Is it always less than 2 on this machine?Quoted 4 lines
Yes:
openrisc_sim_machine_init()setsmc->max_cpus= 2. My suggestion of adding anassert()is essentially telling the compiler that indeedsmp_cpusmust always be in the range [1,2], which we can tell but it can't.Do we have a proper patch for this on the list?
Quoted 8 lines
Quoted 5 lines
Apparently not.
Philippe did try Peter's suggestion, found it works, but then posted it only to Launchpad. Philippe, please post to the list, so we can finally get this fixed.
Sorry since it was Eric finding, I didn't understood I had to post it. Will do.
You didn't *have* to, but it'll help if you do :)
Quoted 9 lines · Markus Armbruster
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Yes:
openrisc_sim_machine_init()setsmc->max_cpus= 2. My suggestion of adding anassert()is essentially telling the compiler that indeedsmp_cpusmust always be in the range [1,2], which we can tell but it can't.Do we have a proper patch for this on the list?
Apparently not.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Philippe did try Peter's suggestion, found it works, but then posted it only to Launchpad. Philippe, please post to the list, so we can finally get this fixed.
Sorry since it was Eric finding, I didn't understood I had to post it. Will do.
You didn't *have* to, but it'll help if you do :)
Now at https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg01779.html
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org