summaryrefslogtreecommitdiff
path: root/ring_rx.c
diff options
context:
space:
mode:
authorJames McCoy <vega.james@gmail.com>2014-05-01 11:14:31 -0400
committerTobias Klauser <tklauser@distanz.ch>2014-05-03 13:36:36 +0200
commit7aa9f970e88382f2508ee55122e27cdcfd8cdbda (patch)
tree03ff36cfad0f1cc88c92b7764fd3b8145207d651 /ring_rx.c
parent7231039ec891acee246549410c70f1151a0c0175 (diff)
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 <vega.james@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ring_rx.c')
-rw-r--r--ring_rx.c9
1 files changed, 5 insertions, 4 deletions
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 <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -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);