I'm not sure whether avoiding incrementing here is an ideal move, but
this diff definitely works toward a local optimum. Namely, that error
check is technically meaningless because signed overflow is undefined.

ok? Or would people prefer a solution that's robust to changing
*curpps's type?


Index: sys/kern/kern_time.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_time.c,v
retrieving revision 1.96
diff -u -p -r1.96 kern_time.c
--- sys/kern/kern_time.c        5 Dec 2015 10:11:53 -0000       1.96
+++ sys/kern/kern_time.c        10 Feb 2016 05:25:35 -0000
@@ -765,20 +765,8 @@ ppsratecheck(struct timeval *lasttime, i
        else
                rv = 0;
 
-#if 1 /*DIAGNOSTIC?*/
-       /* be careful about wrap-around */
-       if (*curpps + 1 > *curpps)
-               *curpps = *curpps + 1;
-#else
-       /*
-        * assume that there's not too many calls to this function.
-        * not sure if the assumption holds, as it depends on *caller's*
-        * behavior, not the behavior of this function.
-        * IMHO it is wrong to make assumption on the caller's behavior,
-        * so the above #if is #if 1, not #ifdef DIAGNOSTIC.
-        */
-       *curpps = *curpps + 1;
-#endif
+       if (*curpps != INT_MAX)
+               (*curpps)++;
 
        return (rv);
 }

Reply via email to