From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10039 invoked by alias); 10 Dec 2004 04:24:27 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9943 invoked from network); 10 Dec 2004 04:24:17 -0000 Received: from unknown (HELO ausmtp02.au.ibm.com) (202.81.18.187) by sourceware.org with SMTP; 10 Dec 2004 04:24:17 -0000 Received: from sd0112e0.au.ibm.com (d23rh903.au.ibm.com [202.81.18.201]) by ausmtp02.au.ibm.com (8.12.10/8.12.10) with ESMTP id iBA4LoCT235956 for ; Fri, 10 Dec 2004 15:21:52 +1100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.250.244]) by sd0112e0.au.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id iBA4PvKI171938 for ; Fri, 10 Dec 2004 15:25:57 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.12.11/8.12.11) with ESMTP id iBA4O5Nt001669 for ; Fri, 10 Dec 2004 15:24:05 +1100 Received: from ozlabs.au.ibm.com (haven.au.ibm.com [9.190.164.82]) by d23av03.au.ibm.com (8.12.11/8.12.11) with ESMTP id iBA4O2kH001573 for ; Fri, 10 Dec 2004 15:24:05 +1100 Received: from namadgi.ozlabs.ibm.com (localhost [127.0.0.1]) by ozlabs.au.ibm.com (Postfix) with SMTP id 676CE17DFC for ; Fri, 10 Dec 2004 15:05:26 +1100 (EST) Received: by namadgi.ozlabs.ibm.com (sSMTP sendmail emulation); Fri, 10 Dec 2004 15:06:50 +1100 From: "Ben Elliston" Date: Fri, 10 Dec 2004 04:31:00 -0000 To: gdb-patches@sources.redhat.com Subject: eliminate warnings in printcmd.c Message-ID: <20041210040650.GB30314@namadgi> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="U+BazGySraz5kW0T" Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i X-SW-Source: 2004-12/txt/msg00258.txt.bz2 --U+BazGySraz5kW0T Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 3582 This patch eliminates warnings whereby the format string is not a string literal and GCC cannot check it at compile-time. I don't expect this patch to be tremendously popular, but my hope is that it will stimulate some discussion on how to really fix it :-) Cheers, Ben 2004-12-10 Ben Elliston * defs.h (printf_filtered_nonliteral): New extern function. * utils.c (printf_filtered_nonliteral): Implement it. * printcmd.c (printf_command): Use it where the format string is not a string literal. Index: defs.h =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: /home/bje/src-cvs/src/gdb/defs.h,v retrieving revision 1.175 diff -u -p -u -r1.175 defs.h --- defs.h 13 Nov 2004 17:00:04 -0000 1.175 +++ defs.h 10 Dec 2004 04:02:27 -0000 @@ -476,6 +476,8 @@ extern void fprintfi_filtered (int, stru =20 extern void printf_filtered (const char *, ...) ATTR_FORMAT (printf, 1, 2); =20 +extern void printf_filtered_nonliteral (const char *, ...); + extern void printfi_filtered (int, const char *, ...) ATTR_FORMAT (printf,= 2, 3); =20 extern void vprintf_unfiltered (const char *, va_list) ATTR_FORMAT (printf= , 1, 0); Index: utils.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: /home/bje/src-cvs/src/gdb/utils.c,v retrieving revision 1.139 diff -u -p -u -r1.139 utils.c --- utils.c 9 Nov 2004 00:59:03 -0000 1.139 +++ utils.c 10 Dec 2004 04:02:29 -0000 @@ -2292,6 +2292,14 @@ printf_filtered (const char *format, ... va_end (args); } =20 +void +printf_filtered_nonliteral (const char *format, ...) +{ + va_list args; + va_start (args, format); + vfprintf_filtered (gdb_stdout, format, args); + va_end (args); +} =20 void printf_unfiltered (const char *format, ...) Index: printcmd.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: /home/bje/src-cvs/src/gdb/printcmd.c,v retrieving revision 1.81 diff -u -p -u -r1.81 printcmd.c --- printcmd.c 12 Nov 2004 21:45:07 -0000 1.81 +++ printcmd.c 10 Dec 2004 04:02:28 -0000 @@ -1946,20 +1946,20 @@ printf_command (char *arg, int from_tty) read_memory (tem, str, j); str[j] =3D 0; =20 - printf_filtered (current_substring, str); + printf_filtered_nonliteral (current_substring, str); } break; case double_arg: { double val =3D value_as_double (val_args[i]); - printf_filtered (current_substring, val); + printf_filtered_nonliteral (current_substring, val); break; } case long_long_arg: #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG) { long long val =3D value_as_long (val_args[i]); - printf_filtered (current_substring, val); + printf_filtered_nonliteral (current_substring, val); break; } #else @@ -1969,7 +1969,7 @@ printf_command (char *arg, int from_tty) { /* FIXME: there should be separate int_arg and long_arg. */ long val =3D value_as_long (val_args[i]); - printf_filtered (current_substring, val); + printf_filtered_nonliteral (current_substring, val); break; } default: /* purecov: deadcode */ --U+BazGySraz5kW0T Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline Content-length: 189 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBuSDaMGpskFPkywkRAjdiAKClqYNj3Hr2nNWVcErygkkjMM16FACfbXOB VyUeg9eZAn7pyJwdB0CWzb8= =BsDB -----END PGP SIGNATURE----- --U+BazGySraz5kW0T--