From owner-freebsd-audit Sun Nov 26 22:19:56 2000 Delivered-To: freebsd-audit@freebsd.org Received: from citusc17.usc.edu (citusc17.usc.edu [128.125.38.177]) by hub.freebsd.org (Postfix) with ESMTP id 3B27637B4F9 for ; Sun, 26 Nov 2000 22:19:54 -0800 (PST) Received: (from kris@localhost) by citusc17.usc.edu (8.11.1/8.11.1) id eAR6KmE46899 for audit@FreeBSD.org; Sun, 26 Nov 2000 22:20:48 -0800 (PST) (envelope-from kris) Date: Sun, 26 Nov 2000 22:20:48 -0800 From: Kris Kennaway To: audit@FreeBSD.org Subject: gcc __attributes for format strings Message-ID: <20001126222048.A46809@citusc17.usc.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Okay, looks like we can play with some gcc attributes to flag things as format strings. For example: Index: create_chunk.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt/ncvs/src/lib/libdisk/create_chunk.c,v retrieving revision 1.54 diff -u -r1.54 create_chunk.c --- create_chunk.c 2000/11/06 23:15:01 1.54 +++ create_chunk.c 2000/11/27 06:14:00 @@ -28,6 +28,8 @@ #include #include "libdisk.h" =20 +static void msgDebug(char *, ...) __printf0like(1,0); + /* Clone these two from sysinstall because we need our own copies * due to link order problems with `crunch'. Feh! */ __printf0like(a,b) says "treat argument 'a' as a printf format string which may be null, and arguments starting with 'b' are the arguments to the format string". b=3D0 is for the case of a varargs function like above. __printflike(a,b) is the same thing except it doesn't allow a NULL format string. We need to go through and prototype functions appropriately (in headers, or internally) - I think it's possible to fix all of the -Wnon-const-format warnings this way. The docs in contrib/gcc/extend.texi explain this better - can someone check that I'm doing the right thing? Kris --YZ5djTAD1cGYuMQK Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjoh/T4ACgkQWry0BWjoQKWbmACg1uufMImPu/tJBZ2MCz4pB0U1 ja4AmwcIYh89suTD4Yx3VlpEnswH9Qcv =ABGF -----END PGP SIGNATURE----- --YZ5djTAD1cGYuMQK-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message