From 234e54b5b647f36ff89d3d6439bf4b6f9ce1d575 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 8 Oct 2010 15:01:12 +0200 Subject: [PATCH] Main: No more calls to GARY_SIZE on an empty timer array --- ucw/mainloop.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ucw/mainloop.c b/ucw/mainloop.c index 561ddd3d..0af9bf14 100644 --- a/ucw/mainloop.c +++ b/ucw/mainloop.c @@ -163,7 +163,10 @@ main_get_time(void) static inline uns count_timers(struct main_context *m) { - return GARY_SIZE(m->timer_table) - 1; + if (m->timer_table) + return GARY_SIZE(m->timer_table) - 1; + else + return 0; } void @@ -562,7 +565,7 @@ static void process_timers(struct main_context *m) { struct main_timer *tm; - while (GARY_SIZE(m->timer_table) > 1 && (tm = m->timer_table[1])->expires <= m->now) + while (count_timers(m) && (tm = m->timer_table[1])->expires <= m->now) { DBG("MAIN: Timer %p expired at now-%lld", tm, (long long)(m->now - tm->expires)); tm->handler(tm); -- 2.39.5