On 5/26/20 8:51 PM, Eric Blake wrote:
> 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.
>
> Signed-off-by: Eric Blake <email address hidden>
> ---
> hw/openrisc/openrisc_sim.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
> index d08ce6181199..95011a8015b4 100644
> --- a/hw/openrisc/openrisc_sim.c
> +++ b/hw/openrisc/openrisc_sim.c
> @@ -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] = {};
On 5/26/20 8:51 PM, Eric Blake wrote: hw/openrisc/ openrisc_ sim.o qemu/hw/ openrisc/ openrisc_ sim.c: In function ‘openrisc_ sim_init’ : qemu/hw/ openrisc/ openrisc_ sim.c:87: 42: error: ‘cpu_irqs[0]’ may be used uninitialized in this function [-Werror= maybe-uninitial ized] connect_ irq(s, i, cpu_irqs[ i][irq_ pin]); sim_ompic_ init() containing the line in question. openrisc_ sim.c | 2 +- openrisc_ sim.c b/hw/openrisc/ openrisc_ sim.c .95011a8015b4 100644 openrisc_ sim.c openrisc_ sim.c sim_init( MachineState *machine) >kernel_ filename;
> 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/
> /home/eblake/
> /home/eblake/
> 87 | sysbus_
> | ~~~~~~~~^~~
>
> 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_
>
> Signed-off-by: Eric Blake <email address hidden>
> ---
> hw/openrisc/
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/openrisc/
> index d08ce6181199.
> --- a/hw/openrisc/
> +++ b/hw/openrisc/
> @@ -129,7 +129,7 @@ static void openrisc_
> const char *kernel_filename = machine-
> OpenRISCCPU *cpu = NULL;
> MemoryRegion *ram;
> - qemu_irq *cpu_irqs[2];
> + qemu_irq *cpu_irqs[2] = {};
Ah I now remembered why this warning sound familiar: /bugs.launchpad .net/qemu/ +bug/1874073
https:/
Peter suggested a different fix, I tested it, and was expecting Martin
Liska to post an updated patch.
> qemu_irq serial_irq;
> int n;
> unsigned int smp_cpus = machine->smp.cpus;
>