From owner-svn-src-head@FreeBSD.ORG Tue Jan 27 20:26:46 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3191B1065673; Tue, 27 Jan 2009 20:26:46 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1EF528FC12; Tue, 27 Jan 2009 20:26:46 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0RKQkHQ095988; Tue, 27 Jan 2009 20:26:46 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0RKQjq3095984; Tue, 27 Jan 2009 20:26:45 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901272026.n0RKQjq3095984@svn.freebsd.org> From: Luigi Rizzo Date: Tue, 27 Jan 2009 20:26:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187787 - head/sbin/ipfw X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2009 20:26:46 -0000 Author: luigi Date: Tue Jan 27 20:26:45 2009 New Revision: 187787 URL: http://svn.freebsd.org/changeset/base/187787 Log: fix printing of uint64_t values, so we can use WARNS=2 Modified: head/sbin/ipfw/Makefile head/sbin/ipfw/dummynet.c head/sbin/ipfw/ipfw2.c head/sbin/ipfw/ipfw2.h Modified: head/sbin/ipfw/Makefile ============================================================================== --- head/sbin/ipfw/Makefile Tue Jan 27 20:25:55 2009 (r187786) +++ head/sbin/ipfw/Makefile Tue Jan 27 20:26:45 2009 (r187787) @@ -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 Modified: head/sbin/ipfw/dummynet.c ============================================================================== --- head/sbin/ipfw/dummynet.c Tue Jan 27 20:25:55 2009 (r187786) +++ head/sbin/ipfw/dummynet.c Tue Jan 27 20:26:45 2009 (r187787) @@ -157,12 +157,13 @@ list_queues(struct dn_flow_set *fs, stru 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, stru 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, 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); Modified: head/sbin/ipfw/ipfw2.c ============================================================================== --- head/sbin/ipfw/ipfw2.c Tue Jan 27 20:25:55 2009 (r187786) +++ head/sbin/ipfw/ipfw2.c Tue Jan 27 20:26:45 2009 (r187787) @@ -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)); Modified: head/sbin/ipfw/ipfw2.h ============================================================================== --- head/sbin/ipfw/ipfw2.h Tue Jan 27 20:25:55 2009 (r187786) +++ head/sbin/ipfw/ipfw2.h Tue Jan 27 20:26:45 2009 (r187787) @@ -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);