diff options
author | James McCoy <vega.james@gmail.com> | 2014-05-01 11:14:31 -0400 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2014-05-03 13:36:36 +0200 |
commit | 7aa9f970e88382f2508ee55122e27cdcfd8cdbda (patch) | |
tree | 03ff36cfad0f1cc88c92b7764fd3b8145207d651 /flowtop.c | |
parent | 7231039ec891acee246549410c70f1151a0c0175 (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 'flowtop.c')
-rw-r--r-- | flowtop.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -22,6 +22,7 @@ #include <sys/fsuid.h> #include <urcu.h> #include <libgen.h> +#include <inttypes.h> #include "die.h" #include "xmalloc.h" @@ -751,7 +752,7 @@ static void presenter_screen_do_line(WINDOW *screen, struct flow_entry *n, /* PID, application name */ if (n->procnum > 0) { - slprintf(tmp, sizeof(tmp), "%s(%u)", basename(n->cmdline), + slprintf(tmp, sizeof(tmp), "%s(%d)", basename(n->cmdline), n->procnum); printw("["); @@ -806,7 +807,7 @@ static void presenter_screen_do_line(WINDOW *screen, struct flow_entry *n, /* Number packets, bytes */ if (n->counter_pkts > 0 && n->counter_bytes > 0) - printw(" (%llu pkts, %llu bytes) ->", + printw(" (%"PRIu64" pkts, %"PRIu64" bytes) ->", n->counter_pkts, n->counter_bytes); /* Show source information: reverse DNS, port, country, city */ @@ -815,7 +816,7 @@ static void presenter_screen_do_line(WINDOW *screen, struct flow_entry *n, mvwprintw(screen, ++(*line), 8, "src: %s", n->rev_dns_src); attroff(COLOR_PAIR(1)); - printw(":%u", n->port_src); + printw(":%"PRIu16, n->port_src); if (n->country_src[0]) { printw(" ("); @@ -838,7 +839,7 @@ static void presenter_screen_do_line(WINDOW *screen, struct flow_entry *n, mvwprintw(screen, ++(*line), 8, "dst: %s", n->rev_dns_dst); attroff(COLOR_PAIR(2)); - printw(":%u", n->port_dst); + printw(":%"PRIu16, n->port_dst); if (n->country_dst[0]) { printw(" ("); |