On 20/8/26 12:47, Philippe Mathieu-Daudé wrote:
All functions called by target has_work() handler take a const @cpu
argument. We can now fulfill the comment added in commit c2804566f6
("target/arm: do not clear halting reason in has_work helper"),
qualifying the handler const to denote its idempotency.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
include/hw/core/sysemu-cpu-ops.h | 4 ++--
target/loongarch/internals.h | 2 +-
target/riscv/internals.h | 2 +-
target/s390x/s390x-internal.h | 2 +-
target/alpha/cpu.c | 2 +-
target/arm/cpu.c | 4 ++--
target/avr/cpu.c | 5 +++--
target/hexagon/cpu.c | 4 ++--
target/hppa/cpu.c | 2 +-
target/i386/cpu.c | 2 +-
target/loongarch/cpu.c | 4 ++--
target/m68k/cpu.c | 2 +-
target/microblaze/cpu.c | 2 +-
target/mips/cpu.c | 4 ++--
target/or1k/cpu.c | 2 +-
target/ppc/cpu_init.c | 2 +-
target/riscv/cpu.c | 2 +-
target/rx/cpu.c | 2 +-
target/s390x/cpu-system.c | 2 +-
target/sh4/cpu.c | 2 +-
target/sparc/cpu.c | 4 ++--
target/tricore/cpu.c | 4 ++--
target/xtensa/cpu.c | 4 ++--
23 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 9761bb173c1..ba66359d410 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -141,9 +141,9 @@ int arm_cpu_mmu_index(CPUState *cs, bool ifetch)
* CPU_INTERRUPT_*NMI anyway. So we might as well accept NMI here
* unconditionally.
*/
-static bool arm_cpu_has_work(CPUState *cs)
+static bool arm_cpu_has_work(const CPUState *cs)
{
- ARMCPU *cpu = ARM_CPU(cs);
+ const ARMCPU *cpu = ARM_CPU(cs);
BTW this is why I said "Not sure if this is a good idea so marked as
RFC" in the cover letter. While the left assignment is correct, the
right QOM-generated macros happily cast without checking const-ness.
We can see that as a pre-existing risk.
Still overall enforcing const-ness on has_work() is a long-term win.
Maybe a simple comment here is sufficient to warn.