Date: Sun, 26 Nov 2000 22:20:48 -0800 From: Kris Kennaway <kris@FreeBSD.org> To: audit@FreeBSD.org Subject: gcc __attributes for format strings Message-ID: <20001126222048.A46809@citusc17.usc.edu>
next in thread | raw e-mail | index | archive | help
--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 <pwd.h> #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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001126222048.A46809>