diff options
author | Pedro Alves <palves@redhat.com> | 2015-02-26 18:29:12 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-02-26 18:29:12 +0000 |
commit | 77b64a49e24dd4b5f4c7edb5d4030fe8aa1eec44 (patch) | |
tree | bd4b5c8c78a0837edcbde0d135ca6f96bfc556a7 /gdb/complaints.c | |
parent | 06b73f4199944fb8a7d2c8874f91ed1deb7f4c44 (diff) | |
download | gdb-77b64a49e24dd4b5f4c7edb5d4030fe8aa1eec44.zip gdb-77b64a49e24dd4b5f4c7edb5d4030fe8aa1eec44.tar.gz gdb-77b64a49e24dd4b5f4c7edb5d4030fe8aa1eec44.tar.bz2 |
Add ATTRIBUTE_PRINTF attributes, and fix fallout
Fixes building gdb on x86_64-apple-darwin14 with clang, which produces
a number of warnings from -Wformat-nonliteral.
Ref: https://sourceware.org/ml/gdb/2015-02/msg00047.html
gdb/ChangeLog:
2015-02-26 Pedro Alves <palves@redhat.com>
* auto-load.h (file_is_auto_load_safe): Add ATTRIBUTE_PRINTF.
* complaints.c (vcomplaint): Pass argument FMT directly to
printf-like functions instead of complaint->fmt.
* ctf.c (ctf_save_write_metadata): Add ATTRIBUTE_PRINTF.
* darwin-nat.c (inferior_debug): Add ATTRIBUTE_PRINTF.
* compile/compile-loc2c.c (pushf, unary, binary): Add
ATTRIBUTE_PRINTF.
(do_compile_dwarf_expr_to_c): Pass string literal as format string
to pushf.
(BINARY): Pass string literal as format string to 'binary'.
* compile/compile-object-load.c (link_callbacks_einfo): Add
ATTRIBUTE_PRINTF.
* guile/guile-internal.h (gdbscm_printf): Add ATTRIBUTE_PRINTF.
Diffstat (limited to 'gdb/complaints.c')
-rw-r--r-- | gdb/complaints.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gdb/complaints.c b/gdb/complaints.c index 7e52656..dbacb2a 100644 --- a/gdb/complaints.c +++ b/gdb/complaints.c @@ -183,21 +183,27 @@ vcomplaint (struct complaints **c, const char *file, else series = complaints->series; + /* Pass 'fmt' instead of 'complaint->fmt' to printf-like callees + from here on, to avoid "format string is not a string literal" + warnings. 'fmt' is this function's printf-format parameter, so + the compiler can assume the passed in argument is a literal + string somewhere up the call chain. */ + gdb_assert (complaint->fmt == fmt); + if (complaint->file != NULL) - internal_vwarning (complaint->file, complaint->line, - complaint->fmt, args); + internal_vwarning (complaint->file, complaint->line, fmt, args); else if (deprecated_warning_hook) - (*deprecated_warning_hook) (complaint->fmt, args); + (*deprecated_warning_hook) (fmt, args); else { if (complaints->explanation == NULL) /* A [v]warning() call always appends a newline. */ - vwarning (complaint->fmt, args); + vwarning (fmt, args); else { char *msg; struct cleanup *cleanups; - msg = xstrvprintf (complaint->fmt, args); + msg = xstrvprintf (fmt, args); cleanups = make_cleanup (xfree, msg); wrap_here (""); if (series != SUBSEQUENT_MESSAGE) |