From cb30b7185f6af0299f2ceab6072aa9030f6f3a5c Mon Sep 17 00:00:00 2001 From: Jeff Lucovsky Date: Fri, 23 Jun 2023 09:00:33 -0400 Subject: [PATCH] detect/stat: Display 0 instead of nan This commit updates the summary message when Suricata terminates. Without this commit, "nan" was displayed if there were no drops/packets --- src/util-device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util-device.c b/src/util-device.c index 74a51c9f10..cc38bbd76f 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -321,7 +321,9 @@ int LiveDeviceListClean(void) SCLogNotice("%s: packets: %" PRIu64 ", drops: %" PRIu64 " (%.2f%%), invalid chksum: %" PRIu64, pd->dev, SC_ATOMIC_GET(pd->pkts), SC_ATOMIC_GET(pd->drop), - 100 * ((double)SC_ATOMIC_GET(pd->drop)) / (double)SC_ATOMIC_GET(pd->pkts), + SC_ATOMIC_GET(pd->pkts) > 0 ? 100 * ((double)SC_ATOMIC_GET(pd->drop)) / + (double)SC_ATOMIC_GET(pd->pkts) + : 0, SC_ATOMIC_GET(pd->invalid_checksums)); }