All TCG targets implement the TCGCPUOps::has_work() handler. We can remove the non-NULL handler check in tcg_cpu_has_work().
Add an assertion in tcg_exec_realizefn() for future TCG targets. Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> --- accel/tcg/cpu-exec.c | 4 ++++ accel/tcg/tcg-accel-ops.c | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 5fd1ed34222..18c20e5759b 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -993,6 +993,10 @@ void tcg_exec_realizefn(CPUState *cpu, Error **errp) CPUClass *cc = CPU_GET_CLASS(cpu); if (!tcg_target_initialized) { + /* Mandatory non-NULL handlers */ + g_assert(cc->tcg_ops->initialize); + g_assert(cc->tcg_ops->has_work); + cc->tcg_ops->initialize(); tcg_target_initialized = true; } diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 3c75ed2cccc..6cd32f04cb9 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -78,10 +78,7 @@ static bool tcg_cpu_has_work(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); - if (cc->tcg_ops->has_work) { - return cc->tcg_ops->has_work(cpu); - } - return false; + return cc->tcg_ops->has_work(cpu); } /* mask must never be zero, except for A20 change call */ -- 2.31.1