From: stefan Date: Thu, 23 Jun 2016 18:41:44 +0000 (+0000) Subject: Avoid multiple evaluation of macro arguments in softclock() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e2738e62da3dc2f56eb5fe7af2f7c63a9280d4b5;p=openbsd Avoid multiple evaluation of macro arguments in softclock() ok mikeb@ tedu@ --- diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 47257a2790a..8862af246f9 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_timeout.c,v 1.46 2016/06/14 15:58:03 bluhm Exp $ */ +/* $OpenBSD: kern_timeout.c,v 1.47 2016/06/23 18:41:44 stefan Exp $ */ /* * Copyright (c) 2001 Thomas Nordin * Copyright (c) 2000-2001 Artur Grabowski @@ -336,6 +336,8 @@ timeout_hardclock_update(void) void softclock(void *arg) { + int delta; + struct circq *bucket; struct timeout *to; void (*fn)(void *); @@ -345,14 +347,14 @@ softclock(void *arg) CIRCQ_REMOVE(&to->to_list); /* If due run it, otherwise insert it into the right bucket. */ - if (to->to_time - ticks > 0) { - CIRCQ_INSERT(&to->to_list, - &BUCKET((to->to_time - ticks), to->to_time)); + delta = to->to_time - ticks; + if (delta > 0) { + bucket = &BUCKET(delta, to->to_time); + CIRCQ_INSERT(&to->to_list, bucket); } else { #ifdef DEBUG - if (to->to_time - ticks < 0) - printf("timeout delayed %d\n", to->to_time - - ticks); + if (delta < 0) + printf("timeout delayed %d\n", delta); #endif to->to_flags &= ~TIMEOUT_ONQUEUE; to->to_flags |= TIMEOUT_TRIGGERED;