Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 May 2002 19:24:17 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Dima Dorfman <dima@trit.org>
Cc:        audit@FreeBSD.ORG
Subject:   Re: %j for printf(9)
Message-ID:  <20020523185629.L12973-100000@gamplex.bde.org>
In-Reply-To: <20020523050017.E3A2A3E22@turbine.trit.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 23 May 2002, Dima Dorfman wrote:

> Attached is a patch that implements the %j length modifier in
> printf(9).  I would appreciate it if someone could test it on one (or
> ...
> I would also appreciate it if someone could review this, particularly
> looking for anywhere I assume signed or unsigned where I shouldn't
> (I'm concerned with mis-{sign,zero}-extension).
> ...
> See message-id <20020405080000.754FB3E31@bazooka.trit.org> for the
> discussion on -standards.  The patch has not changed since then.

I'm still not keen on the lm changes.

Printf is used more than it used to be for formatting sysctl strings,
(e.g. in for malloc statistics), so its efficiency may actually be
important and the change to doing everything related to integers in
uintmax_t precision might be too inefficient.  Some of my debugging
sysctls take a second or so to format large trace buffers.  I think
the error is mainly in the sysctls though.  Production-quality sysctls
shouldn't take longer than a few microseconds.

> I would also like to solicit comments on what to do with %z; C99 says
> this is the length modifier for size_t, but the kernel treats it as
> signed hex.  This patch implements the C99 length modifier as %Z, but
> that probably shouldn't stay.

Just change %z globally in the kernel.

> IIRC, I couldn't find any place in the
> kernel that we actually use %z; can it perhaps be removed?

It is used only in a couple of places, mainly in ddb.  Grep for '".*%.*z'
in sys/ddb to see some of them.  Hack gcc to warn about %z to find all
of them except possibly non-literal ones.

%n should be changed similary.  I think %n was changed globally to %r long
ago to fix an old conflict, but it was not removed from printf(9), so
correct use of %n would pass gcc's format checker but printf(9) would
do the wrong thing.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020523185629.L12973-100000>