summaryrefslogtreecommitdiffstats
path: root/sbin/ping
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2006-08-14 07:54:17 +0000
committerdd <dd@FreeBSD.org>2006-08-14 07:54:17 +0000
commit462216939a87cd70e07c6b7af698d3da3f98cb25 (patch)
tree3b9d1573be266bf922ef9a55259d3a198d8e6bbc /sbin/ping
parent813df8630113217f100ba3304f91f40b46b5fc8e (diff)
downloadFreeBSD-src-462216939a87cd70e07c6b7af698d3da3f98cb25.zip
FreeBSD-src-462216939a87cd70e07c6b7af698d3da3f98cb25.tar.gz
Print packet loss figures with one decimal place. ping6 already does
this, and OpenBSD and NetBSD pings do it too. This is primarily useful for comparing low levels of packet loss.
Diffstat (limited to 'sbin/ping')
-rw-r--r--sbin/ping/ping.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index 2d4a9bd..90e2869 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -1356,7 +1356,7 @@ check_status()
if (siginfo_p) {
siginfo_p = 0;
- (void)fprintf(stderr, "\r%ld/%ld packets received (%.0f%%)",
+ (void)fprintf(stderr, "\r%ld/%ld packets received (%.1f%%)",
nreceived, ntransmitted,
ntransmitted ? nreceived * 100.0 / ntransmitted : 0.0);
if (nreceived && timing)
@@ -1387,9 +1387,9 @@ finish()
if (nreceived > ntransmitted)
(void)printf("-- somebody's printing up packets!");
else
- (void)printf("%d%% packet loss",
- (int)(((ntransmitted - nreceived) * 100) /
- ntransmitted));
+ (void)printf("%.1f%% packet loss",
+ ((ntransmitted - nreceived) * 100.0) /
+ ntransmitted);
}
if (nrcvtimeout)
(void)printf(", %ld packets out of wait time", nrcvtimeout);
OpenPOWER on IntegriCloud