From nobody Wed Oct 11 18:01:02 2023 X-Original-To: dev-commits-src-main@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 4S5LDG2nw5z4wTl6; Wed, 11 Oct 2023 18:01:02 +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 4S5LDG2MVcz4PZH; Wed, 11 Oct 2023 18:01:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697047262; 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=fdX2TOm+FX2BxLMAK54Ch32VkNrjcldM0swXajxPcBY=; b=N1xZpmFEM/iMHVP1F4PNvROXt+NhMHOlpGi6KKVlks8J0ztOni1DZ6jONGXxoQzMB3ruvV sUI21ge6f9w1QSnEGkBj9bjjN823dR5wYQCEDX/xHprQoLYCiLI/5prCQMpIcd2Nc4aDZb OkQMvFj4QPjzTW5/T4W2fwri30qaiYtRYJ96/wN+IX5qdQdRAV8iaM7hhrEAtzjFdVkUBv 3IExE9LZdXPWvkCB1xTybYPNMJawUoM4GdDMwMSFUMxKNUdFBNFEBHil7T3UDiS3CaYdFp 1LrJngLI4Pj5W0MJGwYUJJD8BFcIx/Gsm+521S84FSYVQwceT2n8CPHAwKPu/g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697047262; a=rsa-sha256; cv=none; b=H6eSN5yYX88mxVV9SU3UjzmGE67+rr76cFnH2qfaxcr9nV+09j0E5ETNop8aRv+UbTp06M bGW1hR0T4qCKB1EkNXFecefv9eenwqfsLik1Bqx2oT30+uVbHSFF5ggYMWMwp+7W1MVUDI 3wpjnamyY5Gx0I/yCRgJ3jUPe1T2oh3crd/LXg/HtCece5LRZyP3+CCNjPs4blywqulUSZ +cUZMwwhO4R5xnXdB1xM+kBC4KB3+2iaWascuDDNYe8d3Sb1OCHwilz73sKgVmEcbDuDRF StmE1FlHNTR4ihVuKnerCEEYNJtGymxCMVzIAvxw45u9BU3+p4LlZbbvFRL53Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697047262; 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=fdX2TOm+FX2BxLMAK54Ch32VkNrjcldM0swXajxPcBY=; b=FFwtlXGgnUx1df5cgu6y8iwFxyb0AU53y2bgAKLMUATk8ovU6eqjf3mTqhxjClHBkLE76Y lmmiv5aGBfhEJ0H918ENdnQIJbWPmMt8bCpZ1yO+na4n8P8+nBbYnSLyn1qAK5UWij+IVR yq1WeKBP/eBelv+TbJBkMViNhS2S8zuGxsFT1FAqGen7zfMokBFXxymEAmQf9rQbK184NU TYwoHTNrM7OThnH91fW715qQvHpl0kCnorPun6SrFf5ol2lBqcV/uUv5Zcy+WrPnkCEV01 RzbMqoRcCgAwN1eQDzZv8Z5flxUXb/trgy8BhAo4s8OtiQ23MM6EaZlDg6CtVA== 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 4S5LDG1Qy8zWNY; Wed, 11 Oct 2023 18:01:02 +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 39BI12Na053619; Wed, 11 Oct 2023 18:01:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39BI12KA053616; Wed, 11 Oct 2023 18:01:02 GMT (envelope-from git) Date: Wed, 11 Oct 2023 18:01:02 GMT Message-Id: <202310111801.39BI12KA053616@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4d348e83b738 - main - ping: Avoid reporting NaNs List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 4d348e83b738347f6aaf2b110459a01c5402d04e Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4d348e83b738347f6aaf2b110459a01c5402d04e commit 4d348e83b738347f6aaf2b110459a01c5402d04e Author: Jose Luis Duran AuthorDate: 2023-10-06 17:55:06 +0000 Commit: Mark Johnston CommitDate: 2023-10-11 17:48:27 +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 --- 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 072d4607f745..f67d85f30a5d 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1522,10 +1522,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 bd1658f9500a..d14da9c67a52 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);