qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-timer: simplify qemu_run_timers
@ 2012-09-19 13:52 Paolo Bonzini
  2012-09-22 16:22 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2012-09-19 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

ptimer_head is an invariant pointer to clock->active_timers.
Remove it, and just reference clock->active_timers directly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-timer.c | 7 +++----
 1 file modificato, 3 inserzioni(+), 4 rimozioni(-)

diff --git a/qemu-timer.c b/qemu-timer.c
index c7a1551..908a103 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -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) */
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-timer: simplify qemu_run_timers
  2012-09-19 13:52 [Qemu-devel] [PATCH] qemu-timer: simplify qemu_run_timers Paolo Bonzini
@ 2012-09-22 16:22 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2012-09-22 16:22 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-trivial, qemu-devel

On Wed, Sep 19, 2012 at 03:52:44PM +0200, Paolo Bonzini wrote:
> ptimer_head is an invariant pointer to clock->active_timers.
> Remove it, and just reference clock->active_timers directly.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-22 16:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-19 13:52 [Qemu-devel] [PATCH] qemu-timer: simplify qemu_run_timers Paolo Bonzini
2012-09-22 16:22 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).