From owner-svn-src-all@FreeBSD.ORG Wed Apr 10 16:01:45 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A239A55C; Wed, 10 Apr 2013 16:01:45 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 952CE820; Wed, 10 Apr 2013 16:01:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3AG1jIS083573; Wed, 10 Apr 2013 16:01:45 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3AG1jZq083572; Wed, 10 Apr 2013 16:01:45 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201304101601.r3AG1jZq083572@svn.freebsd.org> From: "Kenneth D. Merry" Date: Wed, 10 Apr 2013 16:01:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249334 - head/usr.bin/ctlstat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Apr 2013 16:01:45 -0000 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;