From nobody Mon Nov 06 16:45:49 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 4SPHKT3fDdz50F60; Mon, 6 Nov 2023 16:45:49 +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 4SPHKT37yHz4GQd; Mon, 6 Nov 2023 16:45:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699289149; 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=jqM7GSTuuV5e6f4c4GCaHX3UaDcDxVy4mNKJmWwsY+g=; b=ViatHiFr7MffzAsgh5aLRE+TS+Ao1zsdNgQxp5jmJgU6u9a5hF6ygo46YjkUjKlU77x+8P eLVxTfjswNvJMP4LHvnAiaT2rLZ6A42M+y2qytwRkbXtRX8EY2ks44V1Azll4TQthlKHGo XDYg0k9iniKP2482C9YLDXAiMvEHXr24pN4ER0R4uHjDtWAsM17ly2nd4Pfxmc1FKjBgqx tWn/VAdp+hH6EBbHY3K//uvukMRZ/Y8nAK68M+XpEN2riaoEpO5fS/GsKBVVNMPj08UgcB aElKua23BcKNe3aq2px3himiZYE6X7GSv1xVE9MYukGa8jNTvMX3hRiKS7ryow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699289149; 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=jqM7GSTuuV5e6f4c4GCaHX3UaDcDxVy4mNKJmWwsY+g=; b=kwIzjLmBhd8UKIOkGLk+aiBv8ToNZYV+Wc4IOAFGwKfEbICIx6Z5mntxtFhXixI9rda3Ya Y5s2fn8IbqUbK3JVU3NPev4dw/UFGU/S2e5VsO34hQfy0+vJmF4YNj4dpFbAFsesFmmpib emt55NHXuxFAFuYQhn+aPakX37fbWhZSw9R8aKp/ZdxadZlA+apDLpQnIoMH6jrzGAy6k9 l5OOMZUKZ98wTf2Cnml9wYfKfI99oFWyAtrOVFudWyfwRRAAN1dBaC2pRaBfOXRLa1H5b9 Bn69s/1ldAKWcIx9g7+azKxkxBjrCvZ2rhXqdApgHS/i3AM2Wgs1C6FWZP1Ldw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699289149; a=rsa-sha256; cv=none; b=nokZTUCwOWrXn8Ube+83dlBsCxBLRwTlfr4ccfrDqGeaGxX03Rpu/m8gPFNcJSfSzPlLkD Y6/NCwvkejvmgrcIYqLDZMdjHZN9ak4JydYok8/ZMGqJUyXihrEskBuIQRgZUZ9iI4d5sA D3cNFTdUn5VcmR/lPoZRdBUGluIhwf7Sv8e8l3Lg4nTZnLeD7epNsihBISVJd/XdnUlDrb yNeMitd89gc230ffVN6U32jGdOFUFkgcdMh1GshmcXAAFf2Aept07jzL0RmfVPTNqaBG5a NncZV7ICRBtKWOWMLn98b86U6S5Qlluyms25RYCWVtCydG5s5vX2DeNh1EAo6g== 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 4SPHKT2BlFzqV; Mon, 6 Nov 2023 16:45:49 +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 3A6Gjnd7058234; Mon, 6 Nov 2023 16:45:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A6Gjn8T058231; Mon, 6 Nov 2023 16:45:49 GMT (envelope-from git) Date: Mon, 6 Nov 2023 16:45:49 GMT Message-Id: <202311061645.3A6Gjn8T058231@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: bf7f8a4e60ce - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: bf7f8a4e60ce450bf31e6ae110e6e37c85ee5eb0 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=bf7f8a4e60ce450bf31e6ae110e6e37c85ee5eb0 commit bf7f8a4e60ce450bf31e6ae110e6e37c85ee5eb0 Author: Jose Luis Duran AuthorDate: 2023-10-06 17:55:06 +0000 Commit: Mark Johnston CommitDate: 2023-11-06 16:45:43 +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 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);