From nobody Mon Nov 13 15:21:14 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4STY6f4dTRz515kD; Mon, 13 Nov 2023 15:21:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4STY6f4Bv6z3Tk2; Mon, 13 Nov 2023 15:21:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699888874; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KUzTQlz/Ne3M3NDg2XHT6S5/3zuDNNAotQwFlD/Orqo=; b=Jzo2tLi/PoPlpi4FMIYZxkMJsjkr/4gA7pte42+mb6pL0jkuZLwXUb6tjJA3LNu2i16B1/ cSTIFj5APPvVy0P7xL4h38sLyOcCHcCeM5VDfmnSgfitM1eauRc1Y9HKwS2Dju3c+Etz7p 7RLop1BOVaKeQa71dXszqc62R4tV+czx/wGF93YbtnMrtcN7Ly1QCAQuLw8OcW5W7mfmEg T8Epgf46psKG+Ny7fD9XfK36jfAC1I8rga64ivUOx2KusflE1GbwA8MgL8UHu2ZfzEzDKu MnPxZOYQINVbiXft001jIivRZcvNh9c2Otj5aD827RtAlBJyIrAm1Rf9jMkQgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699888874; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KUzTQlz/Ne3M3NDg2XHT6S5/3zuDNNAotQwFlD/Orqo=; b=O0V1pM0GHjMNrJc2E5n48vRvk1a2pJqjz6CIxrSYrpkzfR3lIXrINlCrBVe+AlQuzj4+7I ycnzwcCHFYl4Y7INFPq9adDwZ6YPhjPsD+ZFvCu9b410vvJwO2zzBXMaIlvSeL9Gt2GmiG bmn3v5CxfHiy0EGOBc7QMhPUUGozlhFheVCsAfPeNMjKBiIhKsGPrNX5aPd/zdPTxTs0Uz PpwYeOq721lwzuEQdmtUuxa6sTihhAHDdT4Hbc9jO6P/CfcPWeu9ziZugTVg8w9ofE+7qz V/n7P0KOVgr868zKX3fyQBbUAfh7fOlLa3EqMR7TO21dNgi/6zguJp2P3tH9mg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699888874; a=rsa-sha256; cv=none; b=I+HDU0RV0/x1urQ/jpQHczzclXMO54UEOXbq2k37aGL1aBWe581fF/8ffc6P8GXf9hGgG4 Qiu6ndxNsQoSbMwexb6/N4fD2PEgErmEs050r7XYAx/xaXtfxQA/sYt8OabmVmel87y+m1 IkdkrcPjRdZdgAyLdqwMXK7hlxVf8/38KxR8pxZuJm7LYcZrTlSZjLOpEs+biD7pSudYVW 8dU1mid/G5mSJHfzwCKOpRj2abWzwamFBQ83CuceEalVQymizpCLojt6PP9e3darGGxRw+ GN7GlBXdnkQYBo73YqNib5KIoKc4p21ah1qTJQj507qL0idfAsvSZkWLLQkd+Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4STY6f3Fmcz19VX; Mon, 13 Nov 2023 15:21:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3ADFLEWK053887; Mon, 13 Nov 2023 15:21:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ADFLEWi053884; Mon, 13 Nov 2023 15:21:14 GMT (envelope-from git) Date: Mon, 13 Nov 2023 15:21:14 GMT Message-Id: <202311131521.3ADFLEWi053884@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 29667c6fcc36 - stable/13 - ping: Avoid reporting NaNs List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 29667c6fcc36de5cf28942bd72e5b5f5926d19f5 Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=29667c6fcc36de5cf28942bd72e5b5f5926d19f5 commit 29667c6fcc36de5cf28942bd72e5b5f5926d19f5 Author: Jose Luis Duran AuthorDate: 2023-10-06 17:55:06 +0000 Commit: Mark Johnston CommitDate: 2023-11-13 15:20:50 +0000 ping: Avoid reporting NaNs Avoid calculating the square root of negative zero, which can easily happen on certain architectures when calculating the population standard deviation with a sample size of one, e.g., 0.01 - (0.1 * 0.1) = -0.000000. Avoid returning a NaN by capping the minimum possible variance value to zero (positive). In the future, maybe skip reporting statistics at all for a single sample. Reported by: Jenkins Reviewed by: asomers MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D42114 (cherry picked from commit 4d348e83b738347f6aaf2b110459a01c5402d04e) --- sbin/ping/ping.c | 4 ++-- sbin/ping/ping6.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index f248a0eb738c..e121ebdb19e2 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1521,10 +1521,10 @@ finish(void) if (nreceived && timing) { double n = nreceived + nrepeats; double avg = tsum / n; - double vari = tsumsq / n - avg * avg; + double stddev = sqrt(fmax(0, tsumsq / n - avg * avg)); (void)printf( "round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\n", - tmin, avg, tmax, sqrt(vari)); + tmin, avg, tmax, stddev); } if (nreceived) diff --git a/sbin/ping/ping6.c b/sbin/ping/ping6.c index 432a59bf1303..0edeb01b2dc0 100644 --- a/sbin/ping/ping6.c +++ b/sbin/ping/ping6.c @@ -2349,10 +2349,10 @@ summary(void) /* Only display average to microseconds */ double num = nreceived + nrepeats; double avg = tsum / num; - double dev = sqrt(tsumsq / num - avg * avg); + double stddev = sqrt(fmax(0, tsumsq / num - avg * avg)); (void)printf( "round-trip min/avg/max/std-dev = %.3f/%.3f/%.3f/%.3f ms\n", - tmin, avg, tmax, dev); + tmin, avg, tmax, stddev); (void)fflush(stdout); } (void)fflush(stdout);