From aa822c3979167b8e9e76087f27e502d0fa6d0164 Mon Sep 17 00:00:00 2001 From: Dima Dorfman Date: Mon, 14 Aug 2006 07:54:17 +0000 Subject: [PATCH] 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. --- sbin/ping/ping.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 2d4a9bdd496d..90e2869dbc35 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);