qemu-timer: simplify qemu_run_timers
PATCH 1/1 qemu-timer: simplify qemu_run_timers
ptimer_head is an invariant pointer to clock->active_timers. Remove it, and just reference clock->active_timers directly.
Signed-off-by Paolo Bonzini <[email protected]>
--- qemu-timer.c | 7 +++----
1 file modificato, 3 inserzioni(+), 4 rimozioni(-)
qemu-timer.c +3 -4
@@ -372,21 +372,20 @@ bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time)void qemu_run_timers (QEMUClock *clock) { -QEMUTimer **ptimer_head, *ts; +QEMUTimer *ts;int64_t current_time;if (!clock->enabled)return ; current_time =qemu_get_clock_ns (clock); - ptimer_head = &clock->active_timers;for (;;) { - ts = *ptimer_head; + ts = clock->active_timers;if (!qemu_timer_expired_ns (ts, current_time)) {break ; }/* remove timer from the list before calling the callback */ - *ptimer_head = ts->next; + clock->active_timers = ts->next; ts->next =NULL ;/* run the callback (the timer list can be modified) */
Signature · 1 line
1.7.12
Stefan Hajnoczi
AppliedQuoted 7 lines · Paolo Bonzini
ptimer_headis an invariant pointer toclock->active_timers. Remove it, and just referenceclock->active_timersdirectly.Signed-off-by Paolo Bonzini <[email protected]>--- qemu-timer.c | 7 +++----1 file modificato, 3 inserzioni(+), 4 rimozioni(-)
qemu_run_timers() is a piece of code that I always have to read line-by-line. This simplification helps a bit, nice.
Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches
Stefan