Message ID | 20230831131348.69032-1-philmd@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | hw/intc/arm_gicv3_its: Avoid maybe-uninitialized error in get_vte() | expand |
Philippe Mathieu-Daudé <philmd@linaro.org> writes: > Fix when using GCC v11.4 (Ubuntu 11.4.0-1ubuntu1~22.04) with CFLAGS=-Og: > > [4/6] Compiling C object libcommon.fa.p/hw_intc_arm_gicv3_its.c.o > FAILED: libcommon.fa.p/hw_intc_arm_gicv3_its.c.o > inlined from ‘lookup_vte’ at hw/intc/arm_gicv3_its.c:453:9, > inlined from ‘vmovp_callback’ at hw/intc/arm_gicv3_its.c:1039:14: > hw/intc/arm_gicv3_its.c:347:9: error: ‘vte.rdbase’ may be used uninitialized [-Werror=maybe-uninitialized] > 347 | trace_gicv3_its_vte_read(vpeid, vte->valid, vte->vptsize, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 348 | vte->vptaddr, vte->rdbase); > | ~~~~~~~~~~~~~~~~~~~~~~~~~~ > hw/intc/arm_gicv3_its.c: In function ‘vmovp_callback’: > hw/intc/arm_gicv3_its.c:1036:13: note: ‘vte’ declared here > 1036 | VTEntry vte; > | ^~~ > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
On Thu, 31 Aug 2023 at 14:13, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > Fix when using GCC v11.4 (Ubuntu 11.4.0-1ubuntu1~22.04) with CFLAGS=-Og: > > [4/6] Compiling C object libcommon.fa.p/hw_intc_arm_gicv3_its.c.o > FAILED: libcommon.fa.p/hw_intc_arm_gicv3_its.c.o > inlined from ‘lookup_vte’ at hw/intc/arm_gicv3_its.c:453:9, > inlined from ‘vmovp_callback’ at hw/intc/arm_gicv3_its.c:1039:14: > hw/intc/arm_gicv3_its.c:347:9: error: ‘vte.rdbase’ may be used uninitialized [-Werror=maybe-uninitialized] > 347 | trace_gicv3_its_vte_read(vpeid, vte->valid, vte->vptsize, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 348 | vte->vptaddr, vte->rdbase); > | ~~~~~~~~~~~~~~~~~~~~~~~~~~ > hw/intc/arm_gicv3_its.c: In function ‘vmovp_callback’: > hw/intc/arm_gicv3_its.c:1036:13: note: ‘vte’ declared here > 1036 | VTEntry vte; > | ^~~ > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Applied to target-arm.next, thanks. -- PMM
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index 43dfd7a35c..5f552b4d37 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -330,23 +330,20 @@ static MemTxResult get_vte(GICv3ITSState *s, uint32_t vpeid, VTEntry *vte) if (entry_addr == -1) { /* No L2 table entry, i.e. no valid VTE, or a memory error */ vte->valid = false; - goto out; + trace_gicv3_its_vte_read_fault(vpeid); + return MEMTX_OK; } vteval = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, &res); if (res != MEMTX_OK) { - goto out; + trace_gicv3_its_vte_read_fault(vpeid); + return res; } vte->valid = FIELD_EX64(vteval, VTE, VALID); vte->vptsize = FIELD_EX64(vteval, VTE, VPTSIZE); vte->vptaddr = FIELD_EX64(vteval, VTE, VPTADDR); vte->rdbase = FIELD_EX64(vteval, VTE, RDBASE); -out: - if (res != MEMTX_OK) { - trace_gicv3_its_vte_read_fault(vpeid); - } else { - trace_gicv3_its_vte_read(vpeid, vte->valid, vte->vptsize, - vte->vptaddr, vte->rdbase); - } + trace_gicv3_its_vte_read(vpeid, vte->valid, vte->vptsize, + vte->vptaddr, vte->rdbase); return res; }
Fix when using GCC v11.4 (Ubuntu 11.4.0-1ubuntu1~22.04) with CFLAGS=-Og: [4/6] Compiling C object libcommon.fa.p/hw_intc_arm_gicv3_its.c.o FAILED: libcommon.fa.p/hw_intc_arm_gicv3_its.c.o inlined from ‘lookup_vte’ at hw/intc/arm_gicv3_its.c:453:9, inlined from ‘vmovp_callback’ at hw/intc/arm_gicv3_its.c:1039:14: hw/intc/arm_gicv3_its.c:347:9: error: ‘vte.rdbase’ may be used uninitialized [-Werror=maybe-uninitialized] 347 | trace_gicv3_its_vte_read(vpeid, vte->valid, vte->vptsize, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 348 | vte->vptaddr, vte->rdbase); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ hw/intc/arm_gicv3_its.c: In function ‘vmovp_callback’: hw/intc/arm_gicv3_its.c:1036:13: note: ‘vte’ declared here 1036 | VTEntry vte; | ^~~ Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/intc/arm_gicv3_its.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)