@samitouri / QOSamiQemu / commits / 8a0e65e9c1

hw/timer/mss_timer: Remove dead code in timer_write()

In timer_write(), we switch() on the address offset to handle registers that need special-casing, with a default case that handles both "unsupported (64-bit mode) register" and "can just write value to st->regs[]". However, as Coverity points out, every register is covered by the special-casing, so the "write to st->regs[]" code path is dead. (timer_read() has a similar structure but there several registers do go through the default code path.) Replace the dead code with an assertion. CID: 1613905 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260512134750.3543639-1-peter.maydell@linaro.org

Peter Maydell committed May 12, 2026 at 14:47 UTC 8a0e65e9c100f28dd607ac2393be1d405ebbe496
1 file changed +5 -8
hw/timer/mss-timer.c
+5 -8
@@ -189,14 +189,11 @@ timer_write(void *opaque, hwaddr offset,
189 break;
190
191 default:
192 - if (addr < R_TIM1_MAX) {
193 - st->regs[addr] = value;
194 - } else {
195 - qemu_log_mask(LOG_GUEST_ERROR,
196 - TYPE_MSS_TIMER": 64-bit mode not supported\n");
197 - return;
198 - }
199 - break;
192 + /* All non-64-bit regs covered by the switch cases */
193 + assert(addr >= R_TIM1_MAX);
194 + qemu_log_mask(LOG_GUEST_ERROR,
195 + TYPE_MSS_TIMER": 64-bit mode not supported\n");
196 + return;
197 }
198 timer_update_irq(st);
199 }