summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/if.c
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2006-07-28 16:09:19 +0000
committeryar <yar@FreeBSD.org>2006-07-28 16:09:19 +0000
commite1db503689ae54aa3513f73b6e1aa4212ded2641 (patch)
treea96eb543030e3d44f3753ab7e82506f8d20fb99b /usr.bin/netstat/if.c
parentaa2529c0155cd13a19220e5ce17be7a511f54099 (diff)
downloadFreeBSD-src-e1db503689ae54aa3513f73b6e1aa4212ded2641.zip
FreeBSD-src-e1db503689ae54aa3513f73b6e1aa4212ded2641.tar.gz
Achieve WARNS=2 by using uintmax_t to pass around 64-bit quantities,
including to printf(). Using uintmax_t is also robust to further extensions in both the C language and the bitwidth of kernel counters. Tested on: i386 amd64 ia64
Diffstat (limited to 'usr.bin/netstat/if.c')
-rw-r--r--usr.bin/netstat/if.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index 1aeb607..6939788 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <libutil.h>
#include <signal.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -101,26 +102,26 @@ pfsync_stats(u_long off __unused, const char *name, int af1 __unused)
printf("%s:\n", name);
#define p(f, m) if (pfsyncstat.f || sflag <= 1) \
- printf(m, (unsigned long long)pfsyncstat.f, plural(pfsyncstat.f))
+ printf(m, (uintmax_t)pfsyncstat.f, plural(pfsyncstat.f))
#define p2(f, m) if (pfsyncstat.f || sflag <= 1) \
- printf(m, (unsigned long long)pfsyncstat.f)
-
- p(pfsyncs_ipackets, "\t%llu packet%s received (IPv4)\n");
- p(pfsyncs_ipackets6, "\t%llu packet%s received (IPv6)\n");
- p(pfsyncs_badif, "\t\t%llu packet%s discarded for bad interface\n");
- p(pfsyncs_badttl, "\t\t%llu packet%s discarded for bad ttl\n");
- p(pfsyncs_hdrops, "\t\t%llu packet%s shorter than header\n");
- p(pfsyncs_badver, "\t\t%llu packet%s discarded for bad version\n");
- p(pfsyncs_badauth, "\t\t%llu packet%s discarded for bad HMAC\n");
- p(pfsyncs_badact,"\t\t%llu packet%s discarded for bad action\n");
- p(pfsyncs_badlen, "\t\t%llu packet%s discarded for short packet\n");
- p(pfsyncs_badval, "\t\t%llu state%s discarded for bad values\n");
- p(pfsyncs_stale, "\t\t%llu stale state%s\n");
- p(pfsyncs_badstate, "\t\t%llu failed state lookup/insert%s\n");
- p(pfsyncs_opackets, "\t%llu packet%s sent (IPv4)\n");
- p(pfsyncs_opackets6, "\t%llu packet%s sent (IPv6)\n");
- p2(pfsyncs_onomem, "\t\t%llu send failed due to mbuf memory error\n");
- p2(pfsyncs_oerrors, "\t\t%llu send error\n");
+ printf(m, (uintmax_t)pfsyncstat.f)
+
+ p(pfsyncs_ipackets, "\t%ju packet%s received (IPv4)\n");
+ p(pfsyncs_ipackets6, "\t%ju packet%s received (IPv6)\n");
+ p(pfsyncs_badif, "\t\t%ju packet%s discarded for bad interface\n");
+ p(pfsyncs_badttl, "\t\t%ju packet%s discarded for bad ttl\n");
+ p(pfsyncs_hdrops, "\t\t%ju packet%s shorter than header\n");
+ p(pfsyncs_badver, "\t\t%ju packet%s discarded for bad version\n");
+ p(pfsyncs_badauth, "\t\t%ju packet%s discarded for bad HMAC\n");
+ p(pfsyncs_badact,"\t\t%ju packet%s discarded for bad action\n");
+ p(pfsyncs_badlen, "\t\t%ju packet%s discarded for short packet\n");
+ p(pfsyncs_badval, "\t\t%ju state%s discarded for bad values\n");
+ p(pfsyncs_stale, "\t\t%ju stale state%s\n");
+ p(pfsyncs_badstate, "\t\t%ju failed state lookup/insert%s\n");
+ p(pfsyncs_opackets, "\t%ju packet%s sent (IPv4)\n");
+ p(pfsyncs_opackets6, "\t%ju packet%s sent (IPv6)\n");
+ p2(pfsyncs_onomem, "\t\t%ju send failed due to mbuf memory error\n");
+ p2(pfsyncs_oerrors, "\t\t%ju send error\n");
#undef p
#undef p2
}
OpenPOWER on IntegriCloud