diff options
author | Stefan Kempf <stefan@cvs.openbsd.org> | 2016-06-23 18:41:45 +0000 |
---|---|---|
committer | Stefan Kempf <stefan@cvs.openbsd.org> | 2016-06-23 18:41:45 +0000 |
commit | e547a96bfd6a3f56adf58b726d52318df7c307e7 (patch) | |
tree | fe3bce592ef8827f1018e1191a23f13329fe5843 /sys/kern | |
parent | 2992f3f66bb34468303d966934ac4a649d80cafd (diff) |
Avoid multiple evaluation of macro arguments in softclock()
ok mikeb@ tedu@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_timeout.c | 16 |
1 files changed, 9 insertions, 7 deletions
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 <nordin@openbsd.org> * Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org> @@ -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; |