Author: ken
Date: Wed Apr 10 16:01:45 2013
New Revision: 249334
URL: http://svnweb.freebsd.org/changeset/base/249334

Log:
  Fix a time calculation error in ctlstat_standard().
  
  ctlstat.c:    When converting a timeval to a floating point
                number in ctlstat_standard(), cast the nanoseconds
                calculation to a long double, so we don't lose
                precision.  Without the cast, we wind up with a
                time in whole seconds only.
  
  Sponsored by: Spectra Logic
  MFC after:    3 days

Modified:
  head/usr.bin/ctlstat/ctlstat.c

Modified: head/usr.bin/ctlstat/ctlstat.c
==============================================================================
--- head/usr.bin/ctlstat/ctlstat.c      Wed Apr 10 11:26:30 2013        
(r249333)
+++ head/usr.bin/ctlstat/ctlstat.c      Wed Apr 10 16:01:45 2013        
(r249334)
@@ -416,9 +416,10 @@ ctlstat_standard(struct ctlstat_context 
        if (F_CPU(ctx) && (getcpu(&ctx->cur_cpu) != 0))
                errx(1, "error returned from getcpu()");
 
-       cur_secs = ctx->cur_time.tv_sec + (ctx->cur_time.tv_nsec / 1000000000);
+       cur_secs = ctx->cur_time.tv_sec +
+               ((long double)ctx->cur_time.tv_nsec / 1000000000);
        prev_secs = ctx->prev_time.tv_sec +
-            (ctx->prev_time.tv_nsec / 1000000000);
+            ((long double)ctx->prev_time.tv_nsec / 1000000000);
 
        etime = cur_secs - prev_secs;
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to