From: Jeff Lucovsky Date: Fri, 23 Jun 2023 13:00:33 +0000 (-0400) Subject: detect/stat: Display 0 instead of nan X-Git-Tag: suricata-7.0.0~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb30b7185f6af0299f2ceab6072aa9030f6f3a5c;p=thirdparty%2Fsuricata.git 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 --- 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)); }