Subject: bin/6198: typo in bin/6197
To: None <gnats-bugs@gnats.netbsd.org>
From: Daniel Hagerty <hag@ai.mit.edu>
List: netbsd-bugs
Date: 09/24/1998 19:52:12
>Number: 6198
>Category: bin
>Synopsis: typo in bin/6197
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Sep 24 17:05:00 1998
>Last-Modified:
>Originator: Daniel Hagerty
>Organization:
>Release: NetBSD 1.3.2
>Environment:
System: NetBSD repo-man.ai.mit.edu 1.3.2 NetBSD 1.3.2 (REPO_MAN) #45: Fri Jun 12 15:09:02 EDT 1998 hag@repo-man.ai.mit.edu:/fs/repo/hag/work/hacking/os/netbsd/src-stable/sys/arch/i386/compile/REPO_MAN i386
>Description:
Misplaced paren in bin/6197. There are too many units in the
world. Corrected patch follows.
>How-To-Repeat:
>Fix:
--- ping.c.orig Tue May 5 04:40:35 1998
+++ ping.c Thu Sep 24 19:38:44 1998
@@ -78,6 +78,7 @@
#include <limits.h>
#include <string.h>
#include <err.h>
+#include <math.h>
#ifdef sgi
#include <bstring.h>
#include <getopt.h>
@@ -177,6 +178,7 @@
double tmin = 999999999;
double tmax = 0;
double tsum = 0; /* sum of all times */
+double tsumsq = 0;
double maxwait = 0;
#ifdef SIGINFO
@@ -833,6 +835,7 @@
(void) memcpy(&tv, icp->icmp_data, sizeof(tv));
triptime = diffsec(&last_rx, &tv);
tsum += triptime;
+ tsumsq += triptime * triptime;
if (triptime < tmin)
tmin = triptime;
if (triptime > tmax)
@@ -1089,10 +1092,14 @@
}
(void)printf("\n");
if (nreceived && (pingflags & F_TIMING)) {
- (void)printf("round-trip min/avg/max = %.3f/%.3f/%.3f ms\n",
- tmin*1000.0,
- (tsum/(nreceived+nrepeats))*1000.0,
- tmax*1000.0);
+ double n = nreceived + nrepeats;
+ double avg = (tsum / n);
+ double variance = (tsumsq / (n - (avg * avg)));
+
+ printf("round-trip min/avg/max/stddev = "
+ "%.3f/%.3f/%.3f/%.3f ms\n",
+ tmin * 1000.0, avg * 1000.0,
+ tmax * 1000.0, sqrt(variance * 1000.0));
if (pingflags & F_FLOOD) {
double r = diffsec(&last_rx, &first_rx);
double t = diffsec(&last_tx, &first_tx);
--- Makefile.orig Tue May 5 02:41:13 1998
+++ Makefile Thu Sep 24 15:27:06 1998
@@ -5,5 +5,6 @@
MAN= ping.8
BINOWN= root
BINMODE=4555
+LDADD+= -lm
.include <bsd.prog.mk>
>Audit-Trail:
>Unformatted: