Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern ts2timo: return ETIMEDOUT instead of failing an ass...



details:   https://anonhg.NetBSD.org/src/rev/60bf6ecb58dc
branches:  trunk
changeset: 785831:60bf6ecb58dc
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Apr 01 12:31:34 2013 +0000

description:
ts2timo: return ETIMEDOUT instead of failing an assertion when the
calculated difference to the target time is zero.

diffstat:

 sys/kern/subr_time.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (42 lines):

diff -r fe7e650516ca -r 60bf6ecb58dc sys/kern/subr_time.c
--- a/sys/kern/subr_time.c      Sun Mar 31 19:45:06 2013 +0000
+++ b/sys/kern/subr_time.c      Mon Apr 01 12:31:34 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_time.c,v 1.12 2013/03/31 16:46:29 christos Exp $  */
+/*     $NetBSD: subr_time.c,v 1.13 2013/04/01 12:31:34 martin Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_time.c,v 1.12 2013/03/31 16:46:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_time.c,v 1.13 2013/04/01 12:31:34 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -241,7 +241,7 @@
 ts2timo(clockid_t clock_id, int flags, struct timespec *ts,
     int *timo, struct timespec *start)
 {
-       int error;
+       int error, res;
        struct timespec tsd;
 
        flags &= TIMER_ABSTIME;
@@ -259,8 +259,12 @@
        if ((error = itimespecfix(ts)) != 0)
                return error;
 
-       *timo = tstohz(ts);
-       KASSERT(*timo > 0);
+       res = tstohz(ts);
+       if (res == 0)
+               return ETIMEDOUT;
+
+       KASSERT(res > 0);
+       *timo = res;
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index