From owner-freebsd-audit Sat Jun 1 6:54:41 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 65F3037B400 for ; Sat, 1 Jun 2002 06:54:34 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id XAA16978; Sat, 1 Jun 2002 23:54:26 +1000 Date: Sat, 1 Jun 2002 23:58:00 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Dag-Erling Smorgrav Cc: Dima Dorfman , Subject: Re: %j for printf(9) In-Reply-To: Message-ID: <20020601233017.Q2458-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 31 May 2002, Dag-Erling Smorgrav wrote: > Complete updated patch attached. > Index: sys/kern/subr_prf.c > =================================================================== > RCS file: /home/ncvs/src/sys/kern/subr_prf.c,v > retrieving revision 1.81 > diff -u -r1.81 subr_prf.c > --- sys/kern/subr_prf.c 29 Apr 2002 09:15:38 -0000 1.81 > +++ sys/kern/subr_prf.c 31 May 2002 16:58:16 -0000 > ... > @@ -491,19 +473,19 @@ > kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap) > { > #define PCHAR(c) {int cc=(c); if (func) (*func)(cc,arg); else *d++ = cc; retval++; } > + const char *percent; Should be with the other char *'s. > char nbuf[MAXNBUF]; > char *p, *q, *d; > u_char *up; > int ch, n; > - u_long ul; > - u_quad_t uq; > - int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot; > + uintmax_t num; > + int base, lflag, jflag, qflag, tmp, width; > + int ladjust, sharpflag, neg, sign, dot; When splitting this, you might consider fixing he disorder in it (but fixing the external disorder and misarrangement of the other declarations of ints should be in a separate patch). > @@ -519,13 +501,15 @@ > padc = ' '; > width = 0; > while ((ch = (u_char)*fmt++) != '%') { > - if (ch == '\0') > + if (ch == '\0') Unrelated style fix :-). > PCHAR(ch); > } > - qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0; > - sign = 0; dot = 0; dwidth = 0; > -reswitch: switch (ch = (u_char)*fmt++) { > + percent = fmt - 1; > + qflag = jflag = lflag = ladjust = sharpflag = > + neg = sign = dot = dwidth = 0; > +reswitch: > + switch (ch = (u_char)*fmt++) { Another unrelated style fix. This one makes the patch harder to read. > @@ -646,15 +621,8 @@ > goto reswitch; > case 'n': > case 'r': > - if (qflag) > - uq = va_arg(ap, u_quad_t); Please remove the 'n' case, and check this a bit. I forgot to remove it soon after rev.1.48. > @@ -752,10 +717,8 @@ > > break; > default: > - PCHAR('%'); > - if (lflag) > - PCHAR('l'); > - PCHAR(ch); > + while (percent < fmt) > + PCHAR(*percent++); > break; > } > } This seems to print all the garbage for %. It might be useful to mark up the garbage. But gcc will detect the garbage at compile time for literal strings. > @@ -908,7 +871,7 @@ > } > > SYSCTL_PROC(_kern, OID_AUTO, msgbuf_clear, > - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clear, 0, > + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clear, 0, Unrelated style fix :-). I like the bulk of the patch. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message