From 28b26c4eced21e503c13e0a8cb6938fb592b4da9 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Tue, 27 Nov 2012 15:05:14 +0100 Subject: [PATCH] xutils: refactor sock_print_net_stats Suggested-by: Jim Binder Signed-off-by: Daniel Borkmann --- src/xutils.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/xutils.c b/src/xutils.c index 59350a0d..409fd184 100644 --- a/src/xutils.c +++ b/src/xutils.c @@ -653,15 +653,17 @@ void sock_print_net_stats(int sock, unsigned long skipped) ret = getsockopt(sock, SOL_PACKET, PACKET_STATISTICS, &kstats, &slen); if (ret > -1) { - printf("\r%12ld frames incoming\n", - 1UL * kstats.tp_packets); - printf("\r%12ld frames passed filter\n", - 1UL * kstats.tp_packets - kstats.tp_drops - skipped); + uint64_t packets = kstats.tp_packets; + uint64_t drops = kstats.tp_drops; + + printf("\r%12ld frames incoming\n", packets); + printf("\r%12ld frames passed filter\n", + packets - drops - skipped); printf("\r%12ld frames failed filter (out of space)\n", - 1UL * kstats.tp_drops + skipped); + drops + skipped); if (kstats.tp_packets > 0) - printf("\r%12.4f%% frame droprate\n", 1.f * - kstats.tp_drops / kstats.tp_packets * 100.f); + printf("\r%12.4f%\% frame droprate\n", + 1.f * drops / packets * 100.f); } } -- 2.11.4.GIT