gcc10: maybe-uninitialized
authorBruce Rogers <brogers@suse.com>
Wed, 22 Apr 2020 14:50:55 +0000 (08:50 -0600)
committerwanchao-xu <wanchao.xu@samsung.com>
Tue, 9 Jan 2024 11:46:49 +0000 (19:46 +0800)
References: boo#1169728

gcc 10 needs some help to understand that indeed cpu_irqs[0] does get
initialized in all cases. In this case an assert is sufficient.

Reported-by: Martin Liška <mliska@suse.cz>
Signed-off-by: Bruce Rogers <brogers@suse.com>
hw/openrisc/openrisc_sim.c

index 79e70493fc77e50556a4a92a4231e1e021d6611f..bc4b71059ff6d922e3cdc83bfc797adf999ac72e 100644 (file)
@@ -134,6 +134,7 @@ static void openrisc_sim_init(MachineState *machine)
     int n;
     unsigned int smp_cpus = machine->smp.cpus;
 
+    assert(smp_cpus >= 1 && smp_cpus <= 2);
     for (n = 0; n < smp_cpus; n++) {
         cpu = OPENRISC_CPU(cpu_create(machine->cpu_type));
         if (cpu == NULL) {