Skip to content

Gcc warning fixes#301

Merged
arichardson merged 7 commits into
CTSRD-CHERI:devfrom
arichardson:gcc-warning-fixes
Nov 14, 2025
Merged

Gcc warning fixes#301
arichardson merged 7 commits into
CTSRD-CHERI:devfrom
arichardson:gcc-warning-fixes

Conversation

@arichardson
Copy link
Copy Markdown
Member

No description provided.

legoater and others added 7 commits November 13, 2025 10:19
GCC13 reports an error :

../util/async.c: In function ‘aio_bh_poll’:
include/qemu/queue.h:303:22: error: storing the address of local variable ‘slice’ in ‘*ctx.bh_slice_list.sqh_last’ [-Werror=dangling-pointer=]
  303 |     (head)->sqh_last = &(elm)->field.sqe_next;                          \
      |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
../util/async.c:169:5: note: in expansion of macro ‘QSIMPLEQ_INSERT_TAIL’
  169 |     QSIMPLEQ_INSERT_TAIL(&ctx->bh_slice_list, &slice, next);
      |     ^~~~~~~~~~~~~~~~~~~~
../util/async.c:161:17: note: ‘slice’ declared here
  161 |     BHListSlice slice;
      |                 ^~~~~
../util/async.c:161:17: note: ‘ctx’ declared here

But the local variable 'slice' is removed from the global context list
in following loop of the same routine. Add a pragma to silent GCC.

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20230420202939.1982044-1-clg@kaod.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit d66ba6dc1cce914673bd8a89fca30a7715ea70d1)
This should be a target_ulong and not a bool. Fortunately, we were
only checking for zero vs non-zero, so this did not happen to matter.
Instead of having a function indexing into the array by mode change it
to handle the AArch64 state only. This was noticed by GCC because we
were potentially indexing into the wrong array in
`arm_cpu_write_elf64_note`. This function always wants the xregs and
not the A32 or AArch64 regs. Since there are only 3 cases that care
about env->regs[] vs env->xregs[] drop the helper function and restore
the upstream code in those places.

```
In function ‘arm_get_xreg’,
    inlined from ‘arm_cpu_write_elf64_note’ at ../../qemu/target/arm/arch_dump.c:259:40:
../../qemu/target/arm/cpu.h:3634:57: warning: iteration 16 invokes undefined behavior [-Waggressive-loop-optimizations]
 3634 |     return (is_a64(env) ? env->xregs[regnum] : env->regs[regnum]);
      |                                                         ^
../../qemu/target/arm/arch_dump.c: In function ‘arm_cpu_write_elf64_note’:
../../qemu/target/arm/arch_dump.c:258:19: note: within this loop
  258 |     for (i = 0; i < 31; ++i) {
      |                   ^
```
Explicitly set AHCIState::ports before calling ahci_realize().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240213081201.78951-8-philmd@linaro.org>
(cherry picked from commit be02150167044e34d3c5ec5d9e84e8470e9a8166)
Do not rely on the detection that was done in the configure script,
since in the future we may want to cross-compile this file.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 43924d1)
Avoids the following bogus warning:

pvh_main.c: In function ‘pvh_load_kernel’:
pvh_main.c:101:42: warning: array subscript 0 is outside array bounds of ‘uint16_t[0]’ {aka ‘short unsigned int[]’} [-Warray-bounds]
  101 |         uint32_t ebda_paddr = ((uint32_t)*((uint16_t *)EBDA_BASE_ADDR)) << 4;
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Cc: qemu-stable@nongnu.org
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 236d152)
@arichardson arichardson merged commit 1f86947 into CTSRD-CHERI:dev Nov 14, 2025
52 checks passed
@arichardson arichardson deleted the gcc-warning-fixes branch November 14, 2025 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants