From 1e0915f4cce08276e201e0fd50d62ee93a02383e Mon Sep 17 00:00:00 2001
From: Erik Auerswald <auerswal@unix-ag.uni-kl.de>
Date: Sun, 30 Jan 2022 16:44:19 +0100
Subject: [PATCH 1/5] guard against a division by zero

If h->num_sent cab be zero in the other branch of the if, it
can be zero here, too.

The almost identical code in print_per_system_split() has
this guard against a division by zero already.
---
 src/fping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/fping.c b/src/fping.c
index d76b23c..887ba9b 100644
--- a/src/fping.c
+++ b/src/fping.c
@@ -1625,7 +1625,7 @@ void print_per_system_stats(void)
             else {
                 fprintf(stderr, " xmt/rcv/%%return = %d/%d/%d%%",
                     h->num_sent, h->num_recv,
-                    ((h->num_recv * 100) / h->num_sent));
+                    h->num_sent > 0 ? ((h->num_recv * 100) / h->num_sent) : 0);
             }
 
             if (h->num_recv) {
-- 
2.25.1

