From 7aa9f970e88382f2508ee55122e27cdcfd8cdbda Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 1 May 2014 11:14:31 -0400 Subject: all: Use macros for printf/scanf format specifiers Any types that are fixed width should use the standard format specifier macros (PRI... for printf-type functions, SCN... for scanf-type functions) to ensure proper data access. Prior to this ifpps was crashing in 32-bit environments due to the following call mvwprintw(screen, (*voff)++, 2, "%s,%s %s (%s%s), t=%lums, cpus=%u%s/%u" " ", uts.release, machine, ifname, drvinf.driver, buff, ms_interval, top_cpus, top_cpus > 0 && top_cpus < cpus ? "+1" : "", cpus); since ms_interval is a uint64_t but %lu expects an unsigned long, which is only 32 bits. Signed-off-by: James McCoy Signed-off-by: Tobias Klauser --- ring_rx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'ring_rx.c') diff --git a/ring_rx.c b/ring_rx.c index 97c485e..a63b126 100644 --- a/ring_rx.c +++ b/ring_rx.c @@ -4,6 +4,7 @@ * Subject to the GPL, version 2. */ +#include #include #include #include @@ -153,10 +154,10 @@ void sock_rx_net_stats(int sock, unsigned long seen) uint64_t packets = stats.k3.tp_packets; uint64_t drops = stats.k3.tp_drops; - printf("\r%12ld packets incoming (%ld unread on exit)\n", - v3 ? seen : packets, v3 ? packets - seen : 0); - printf("\r%12ld packets passed filter\n", packets - drops); - printf("\r%12ld packets failed filter (out of space)\n", drops); + printf("\r%12"PRIu64" packets incoming (%"PRIu64" unread on exit)\n", + v3 ? (uint64_t)seen : packets, v3 ? packets - seen : 0); + printf("\r%12"PRIu64" packets passed filter\n", packets - drops); + printf("\r%12"PRIu64" packets failed filter (out of space)\n", drops); if (stats.k3.tp_packets > 0) printf("\r%12.4lf%% packet droprate\n", (1.0 * drops / packets) * 100.0); -- cgit v1.2.3-54-g00ecf