]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/stat: Display 0 instead of nan
authorJeff Lucovsky <jlucovsky@oisf.net>
Fri, 23 Jun 2023 13:00:33 +0000 (09:00 -0400)
committerJeff Lucovsky <jlucovsky@oisf.net>
Wed, 5 Jul 2023 13:24:37 +0000 (09:24 -0400)
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

index 74a51c9f1069c3539bc9b8952727b234f8de46fb..cc38bbd76fe387de4a9e562f4a24133365c015f5 100644 (file)
@@ -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));
         }