WARNS cleanup for ipfw
Luigi Rizzo
rizzo at icir.org
Sat Mar 6 08:26:25 PST 2004
On Sat, Mar 06, 2004 at 12:19:22PM +0100, Johan Karlsson wrote:
> Hi
>
> the attached patch makes ipfw WARNS=2 clean by using the
> %j/(uintmax_t) combo where so needed. If there are no
> objections I intend to commit this patch.
if align_uint64() is always cast to uintmax_t, why don't
you define it to return the proper type instead ?
Also, where do %j/uintmax_t stand in terms of standards ?
certainly the gcc in 4.x does not like them...
cheers
luigi
> take care
> /Johan K
>
> --
> Johan Karlsson mailto:johan at FreeBSD.org
> Index: sbin/ipfw/Makefile
> ===================================================================
> RCS file: /home/ncvs/src/sbin/ipfw/Makefile,v
> retrieving revision 1.12
> diff -u -r1.12 Makefile
> --- sbin/ipfw/Makefile 11 Jul 2002 17:33:37 -0000 1.12
> +++ sbin/ipfw/Makefile 5 Mar 2004 22:06:10 -0000
> @@ -2,7 +2,7 @@
>
> PROG= ipfw
> SRCS= ipfw2.c
> -WARNS?= 0
> +WARNS?= 2
> MAN= ipfw.8
>
> .include <bsd.prog.mk>
> Index: sbin/ipfw/ipfw2.c
> ===================================================================
> RCS file: /home/ncvs/src/sbin/ipfw/ipfw2.c,v
> retrieving revision 1.45
> diff -u -r1.45 ipfw2.c
> --- sbin/ipfw/ipfw2.c 24 Jan 2004 19:20:09 -0000 1.45
> +++ sbin/ipfw/ipfw2.c 5 Mar 2004 22:05:38 -0000
> @@ -36,6 +36,7 @@
> #include <netdb.h>
> #include <pwd.h>
> #include <signal.h>
> +#include <stdint.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdarg.h>
> @@ -902,8 +903,9 @@
> printf("%05u ", rule->rulenum);
>
> if (pcwidth>0 || bcwidth>0)
> - printf("%*llu %*llu ", pcwidth, align_uint64(&rule->pcnt),
> - bcwidth, align_uint64(&rule->bcnt));
> + printf("%*ju %*ju ", pcwidth,
> + (uintmax_t)align_uint64(&rule->pcnt),
> + bcwidth, (uintmax_t)align_uint64(&rule->bcnt));
>
> if (do_time == 2)
> printf("%10u ", rule->timestamp);
> @@ -1331,9 +1333,9 @@
> bcopy(&d->rule, &rulenum, sizeof(rulenum));
> printf("%05d", rulenum);
> if (pcwidth>0 || bcwidth>0)
> - printf(" %*llu %*llu (%ds)", pcwidth,
> - align_uint64(&d->pcnt), bcwidth,
> - align_uint64(&d->bcnt), d->expire);
> + printf(" %*ju %*ju (%ds)", pcwidth,
> + (uintmax_t)align_uint64(&d->pcnt), bcwidth,
> + (uintmax_t)align_uint64(&d->bcnt), d->expire);
> switch (d->dyn_type) {
> case O_LIMIT_PARENT:
> printf(" PARENT %d", d->count);
> @@ -1423,12 +1425,12 @@
> 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("%4ju %8ju %2u %4u %3u\n",
> + (uintmax_t)q[l].tot_pkts, (uintmax_t)q[l].tot_bytes,
> q[l].len, q[l].len_bytes, q[l].drops);
> if (verbose)
> - printf(" S %20qd F %20qd\n",
> - q[l].S, q[l].F);
> + printf(" S %20jd F %20jd\n",
> + (intmax_t)q[l].S, (intmax_t)q[l].F);
> }
> }
>
> @@ -1517,7 +1519,7 @@
> p->pipe_nr, buf, p->delay);
> print_flowset_parms(&(p->fs), prefix);
> if (verbose)
> - printf(" V %20qd\n", p->V >> MY_M);
> + printf(" V %20jd\n", (intmax_t)p->V >> MY_M);
>
> q = (struct dn_flow_queue *)(p+1);
> list_queues(&(p->fs), q);
> @@ -1743,27 +1745,27 @@
> if (show_counters) {
> for (n = 0, r = data; n < nstat; n++, r = NEXT(r)) {
> /* packet counter */
> - width = snprintf(NULL, 0, "%llu",
> - align_uint64(&r->pcnt));
> + width = snprintf(NULL, 0, "%ju",
> + (uintmax_t)align_uint64(&r->pcnt));
> if (width > pcwidth)
> pcwidth = width;
>
> /* byte counter */
> - width = snprintf(NULL, 0, "%llu",
> - align_uint64(&r->bcnt));
> + width = snprintf(NULL, 0, "%ju",
> + (uintmax_t)align_uint64(&r->bcnt));
> if (width > bcwidth)
> bcwidth = width;
> }
> }
> if (do_dynamic && ndyn) {
> for (n = 0, d = dynrules; n < ndyn; n++, d++) {
> - width = snprintf(NULL, 0, "%llu",
> - align_uint64(&d->pcnt));
> + width = snprintf(NULL, 0, "%ju",
> + (uintmax_t)align_uint64(&d->pcnt));
> if (width > pcwidth)
> pcwidth = width;
>
> - width = snprintf(NULL, 0, "%llu",
> - align_uint64(&d->bcnt));
> + width = snprintf(NULL, 0, "%ju",
> + (uintmax_t)align_uint64(&d->bcnt));
> if (width > bcwidth)
> bcwidth = width;
> }
> _______________________________________________
> freebsd-ipfw at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-ipfw
> To unsubscribe, send any mail to "freebsd-ipfw-unsubscribe at freebsd.org"
More information about the freebsd-ipfw
mailing list