From owner-freebsd-audit Wed Dec 5 12: 0:16 2001 Delivered-To: freebsd-audit@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 719BF37B416; Wed, 5 Dec 2001 12:00:10 -0800 (PST) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 5 Dec 2001 20:00:09 +0000 (GMT) Date: Wed, 5 Dec 2001 20:00:06 +0000 From: David Malone To: Mike Barcroft Cc: audit@freebsd.org, markm@freebsd.org, Bruce Evans , obrien@freebsd.org Subject: Re: Warns for tcopy and wc. Message-ID: <20011205200006.A38562@walton.maths.tcd.ie> References: <20011203215452.E57237@espresso.q9media.com> <200112041341.aa05762@salmon.maths.tcd.ie> <20011204112148.F57237@espresso.q9media.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20011204112148.F57237@espresso.q9media.com>; from mike@freebsd.org on Tue, Dec 04, 2001 at 11:21:48AM -0500 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 Tue, Dec 04, 2001 at 11:21:48AM -0500, Mike Barcroft wrote: > David Malone writes: > > I presume casting to intmax_t will be the oficially blessed way of > > printing typedefed things now? If so we should make gcc's format > > warning code understand the %j modifier - maybe I should look into > > that (or maybe some of the FreeBSD standards people are doing that?). > > Yes, intmax_t is guaranteed to be capable of representing any value of > any signed integer. Similarly, uintmax_t is guaranteed to be capable > of representing any value of any unsigned integer. It would probably > be a good idea to teach GCC about these types. The following patch makes gcc think that intmat_t is the same thing as a long long when it is doing format checking. The list of types gcc knows for format checking is just after line 1060 of c-common.c and long long is the closest thing available. I've included a short shell script which should emit no warnings if gcc has been patched with this patch. If someone could compile and install gcc on the alpha with this patch and then run the shell script to see if it emits a warning, that would be useful. (I'll try to do it myself, but it is hard to test gcc without installing it). David. Index: c-common.c =================================================================== RCS file: /cvs/FreeBSD-CVS/src/contrib/gcc.295/c-common.c,v retrieving revision 1.12 diff -u -r1.12 c-common.c --- c-common.c 25 May 2001 19:00:07 -0000 1.12 +++ c-common.c 5 Dec 2001 19:36:02 -0000 @@ -1777,6 +1777,13 @@ warning ("ANSI C does not support the `%c' length modifier", length_char); } + else if (*format_chars == 'j') + { + length_char = 'q', format_chars++; + if (pedantic) + warning ("ANSI C does not support the `%c' length modifier", + length_char); + } else if (*format_chars == 'Z') { length_char = *format_chars++; #!/bin/sh cat > jtest.c < #include int main() { intmax_t a=0; printf("%jd", a); return 0; } EOF gcc -W -Wall -o jtest jtest.c rm -f jtest.c jtest To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message