aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorLuigi Rizzo <luigi@FreeBSD.org>2009-01-27 20:26:45 +0000
committerLuigi Rizzo <luigi@FreeBSD.org>2009-01-27 20:26:45 +0000
commit50a99912c1efe322196ee8c88bfeb82bccacb921 (patch)
tree5a6b612f20f76de703f4892c47927d4dc47234d3 /sbin
parent2ba7d35b21d1269e9ba4a789832c0b0174eccf86 (diff)
downloadsrc-50a99912c1efe322196ee8c88bfeb82bccacb921.tar.gz
src-50a99912c1efe322196ee8c88bfeb82bccacb921.zip
fix printing of uint64_t values, so we can use WARNS=2
Notes
Notes: svn path=/head/; revision=187787
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ipfw/Makefile2
-rw-r--r--sbin/ipfw/dummynet.c20
-rw-r--r--sbin/ipfw/ipfw2.c14
-rw-r--r--sbin/ipfw/ipfw2.h2
4 files changed, 27 insertions, 11 deletions
diff --git a/sbin/ipfw/Makefile b/sbin/ipfw/Makefile
index 15e45689ddbf..fdf3b80e91ef 100644
--- a/sbin/ipfw/Makefile
+++ b/sbin/ipfw/Makefile
@@ -2,7 +2,7 @@
PROG= ipfw
SRCS= ipfw2.c dummynet.c ipv6.c main.c nat.c
-WARNS?= 0
+WARNS?= 2
MAN= ipfw.8
.include <bsd.prog.mk>
diff --git a/sbin/ipfw/dummynet.c b/sbin/ipfw/dummynet.c
index 88dc33e82ab3..7cf08675fb30 100644
--- a/sbin/ipfw/dummynet.c
+++ b/sbin/ipfw/dummynet.c
@@ -157,12 +157,13 @@ list_queues(struct dn_flow_set *fs, struct dn_flow_queue *q)
ina.s_addr = htonl(q[l].id.dst_ip);
printf("%15s/%-5d ",
inet_ntoa(ina), q[l].id.dst_port);
- printf("%4qu %8qu %2u %4u %3u\n",
- q[l].tot_pkts, q[l].tot_bytes,
+ printf("%4llu %8llu %2u %4u %3u\n",
+ align_uint64(&q[l].tot_pkts),
+ align_uint64(&q[l].tot_bytes),
q[l].len, q[l].len_bytes, q[l].drops);
if (co.verbose)
- printf(" S %20qd F %20qd\n",
- q[l].S, q[l].F);
+ printf(" S %20llu F %20llu\n",
+ align_uint64(&q[l].S), align_uint64(&q[l].F));
}
/* Print IPv6 flows */
@@ -202,11 +203,14 @@ list_queues(struct dn_flow_set *fs, struct dn_flow_queue *q)
printf(" %39s/%-5d ",
inet_ntop(AF_INET6, &(q[l].id.dst_ip6), buff, sizeof(buff)),
q[l].id.dst_port);
- printf(" %4qu %8qu %2u %4u %3u\n",
- q[l].tot_pkts, q[l].tot_bytes,
+ printf(" %4llu %8llu %2u %4u %3u\n",
+ align_uint64(&q[l].tot_pkts),
+ align_uint64(&q[l].tot_bytes),
q[l].len, q[l].len_bytes, q[l].drops);
if (co.verbose)
- printf(" S %20qd F %20qd\n", q[l].S, q[l].F);
+ printf(" S %20llu F %20llu\n",
+ align_uint64(&q[l].S),
+ align_uint64(&q[l].F));
}
}
@@ -295,7 +299,7 @@ ipfw_list_pipes(void *data, uint nbytes, int ac, char *av[])
p->pipe_nr, buf, p->delay);
print_flowset_parms(&(p->fs), prefix);
if (co.verbose)
- printf(" V %20qd\n", p->V >> MY_M);
+ printf(" V %20llu\n", align_uint64(&p->V) >> MY_M);
q = (struct dn_flow_queue *)(p+1);
list_queues(&(p->fs), q);
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index ffd74e85a524..056b01b9d6ca 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -306,8 +306,18 @@ static struct _s_x rule_options[] = {
{ NULL, 0 } /* terminator */
};
-static __inline uint64_t
-align_uint64(uint64_t *pll) {
+/*
+ * The following is used to generate a printable argument for
+ * 64-bit numbers, irrespective of platform alignment and bit size.
+ * Because all the printf in this program use %llu as a format,
+ * we just return an unsigned long long, which is larger than
+ * we need in certain cases, but saves the hassle of using
+ * PRIu64 as a format specifier.
+ * We don't care about inlining, this is not performance critical code.
+ */
+unsigned long long
+align_uint64(const uint64_t *pll)
+{
uint64_t ret;
bcopy (pll, &ret, sizeof(ret));
diff --git a/sbin/ipfw/ipfw2.h b/sbin/ipfw/ipfw2.h
index 14c3837d49ab..dfbb17e3ce14 100644
--- a/sbin/ipfw/ipfw2.h
+++ b/sbin/ipfw/ipfw2.h
@@ -190,6 +190,8 @@ enum tokens {
*/
#define NEED1(msg) {if (!ac) errx(EX_USAGE, msg);}
+unsigned long long align_uint64(const uint64_t *pll);
+
/* memory allocation support */
void *safe_calloc(size_t number, size_t size);
void *safe_realloc(void *ptr, size_t size);