From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Cc: Binutils <binutils@sourceware.org>
Subject: [PATCH 00/18] gdb: Enable -Wwrite-strings (aka remove -Wno-write-strings)
Date: Tue, 04 Apr 2017 17:25:00 -0000 [thread overview]
Message-ID: <1491326751-16180-1-git-send-email-palves@redhat.com> (raw)
"-Wwrite-strings" is enabled by default for C++ programs:
"When compiling C++, warn about the deprecated conversion from
string literals to char *. This warning is enabled by default for
C++ programs. "
This warning, via -Werror, makes this be a compile-time error:
char *str = "hello";
It forces us to write instead either
char *str = (char *) "hello"; // I know what I'm doing! (TM)
or:
const char *str = "hello"; // Preferable.
However, I had disabled the warning for GDB in the earlier steps of
the C++ conversion:
https://sourceware.org/ml/gdb-patches/2015-02/msg00203.html
... as an expedient hack, since we weren't enabling it in C mode
either.
I'd like to enable the warning now, to catch more bugs at compile
time. I spotted one related bug in review last week (storing a string
literal in a vector of heap-allocated strings, leading to a bogus
"free" call later on), which was what prompted me to do this.
"Bah, I'll just do it. Can't take more than a couple hours..."
Yeah, right... /me will never learn.
Tested on x86_64 Fedora 23, built with --enable-targets=all.
Compile tested GDB on Aarch64 GNU/Linux, Power 64 GNU/Linux, AIX 7.1,
and 32-bit/64-bit mingw32-w64.
Also cross built MIPS and ARM GNU/Linux gdbserver.
The first patch needs approval from the binutils side, hence the cross
post. The rest of the series is GDB-specific, so I'm sending those
patches to gdb-patches@ only.
Pedro Alves (18):
-Wwrite-strings: Constify struct disassemble_info's
disassembler_options field
-Wwrite-strings: Constify macroexp.c:init_shared_buffer
-Wwrite-strings: Don't initialize string command variables to empty
string
-Wwrite-strings: Constify shell_escape and plug make_command leak
-Wwrite-strings: Constify warning_pre_print
-Wwrite-strings: Constify target_pid_to_str and
target_thread_extra_thread_info
-Wwrite-strings: Constify work break character arrays
-Wwrite-strings: Constify mi_cmd_argv_ftype's 'command' parameter
-Wwrite-strings: MI -info-os
-Wwrite-strings: gdbserver's 'port' parsing
-Wwrite-strings: gdbserver/win32-low.c and TARGET_WAITKIND_EXECD
-Wwrite-strings: More fix-old-Python-API wrappers
-Wwrite-strings: Wrap PyGetSetDef for construction with string
literals
-Wwrite-strings: Add a PyArg_ParseTupleAndKeywords "const char *"
overload
-Wwrite-strings: execute_command calls with string literals
-Wwrite-strings: Some constification in gdb/breakpoint.c
-Wwrite-strings: The Rest
-Wwrite-strings: Remove -Wno-write-strings
gdb/ada-exp.y | 4 +-
gdb/ada-lang.c | 58 +++++++++---------
gdb/ada-lang.h | 8 +--
gdb/aix-thread.c | 4 +-
gdb/arc-tdep.c | 2 +-
gdb/arm-tdep.c | 4 +-
gdb/ax-gdb.c | 21 ++++---
gdb/bcache.c | 2 +-
gdb/bcache.h | 2 +-
gdb/break-catch-throw.c | 23 ++++---
gdb/breakpoint.c | 38 ++++++------
gdb/breakpoint.h | 8 +--
gdb/bsd-kvm.c | 2 +-
gdb/bsd-uthread.c | 6 +-
gdb/buildsym.c | 2 +-
gdb/buildsym.h | 4 +-
gdb/c-exp.y | 6 +-
gdb/c-lang.h | 4 +-
gdb/c-varobj.c | 2 +-
gdb/charset.c | 11 +++-
gdb/cli/cli-cmds.c | 40 ++++++------
gdb/cli/cli-decode.c | 3 +-
gdb/cli/cli-dump.c | 15 ++---
gdb/cli/cli-script.c | 2 +-
gdb/cli/cli-script.h | 2 +-
gdb/cli/cli-utils.c | 6 +-
gdb/cli/cli-utils.h | 21 ++++++-
gdb/coff-pe-read.c | 2 +-
gdb/command.h | 3 +-
gdb/common/print-utils.c | 2 +-
gdb/completer.c | 62 +++++++++++--------
gdb/completer.h | 8 ++-
gdb/configure | 2 +-
gdb/corefile.c | 2 +-
gdb/corelow.c | 2 +-
gdb/cp-name-parser.y | 4 +-
gdb/cp-valprint.c | 2 +-
gdb/cris-tdep.c | 6 +-
gdb/d-exp.y | 6 +-
gdb/d-lang.h | 2 +-
gdb/darwin-nat.c | 4 +-
gdb/dbxread.c | 80 ++++++++++++------------
gdb/defs.h | 7 ++-
gdb/disasm.c | 2 +-
gdb/dwarf2read.c | 8 +--
gdb/event-top.c | 4 +-
gdb/exceptions.c | 4 +-
gdb/exceptions.h | 3 +-
gdb/expprint.c | 14 ++---
gdb/expression.h | 6 +-
gdb/f-exp.y | 8 +--
gdb/f-lang.c | 2 +-
gdb/f-lang.h | 2 +-
gdb/fbsd-nat.c | 2 +-
gdb/fbsd-tdep.c | 2 +-
gdb/fork-child.c | 2 +-
gdb/frv-tdep.c | 6 +-
gdb/gdbarch.c | 6 +-
gdb/gdbarch.h | 4 +-
gdb/gdbarch.sh | 6 +-
gdb/gdbcore.h | 2 +-
gdb/gdbserver/configure | 2 +-
gdb/gdbserver/gdbreplay.c | 2 +-
gdb/gdbserver/linux-x86-low.c | 2 +-
gdb/gdbserver/remote-utils.c | 8 +--
gdb/gdbserver/remote-utils.h | 4 +-
gdb/gdbserver/server.c | 13 ++--
gdb/gdbserver/win32-low.c | 5 --
gdb/gnu-nat.c | 2 +-
gdb/go-exp.y | 6 +-
gdb/go-lang.h | 2 +-
gdb/go32-nat.c | 4 +-
gdb/guile/scm-breakpoint.c | 3 +-
gdb/guile/scm-cmd.c | 4 +-
gdb/guile/scm-param.c | 2 +-
gdb/h8300-tdep.c | 6 +-
gdb/hppa-tdep.c | 4 +-
gdb/i386-cygwin-tdep.c | 2 +-
gdb/i386-tdep.c | 4 +-
gdb/ia64-tdep.c | 2 +-
gdb/inf-ptrace.c | 2 +-
gdb/infcmd.c | 12 ++--
gdb/inferior.c | 2 +-
gdb/language.c | 10 +--
gdb/language.h | 8 +--
gdb/linespec.c | 3 +-
gdb/linux-nat.c | 2 +-
gdb/linux-tdep.c | 2 +-
gdb/linux-thread-db.c | 6 +-
gdb/lm32-tdep.c | 2 +-
gdb/m2-exp.y | 4 +-
gdb/m2-lang.h | 2 +-
gdb/m32r-tdep.c | 2 +-
gdb/m68hc11-tdep.c | 2 +-
gdb/m88k-tdep.c | 2 +-
gdb/macroexp.c | 28 +++++----
gdb/main.c | 6 +-
gdb/mdebugread.c | 46 +++++++-------
gdb/memattr.c | 2 +-
gdb/mep-tdep.c | 2 +-
gdb/mi/mi-cmd-break.c | 12 ++--
gdb/mi/mi-cmd-catch.c | 8 +--
gdb/mi/mi-cmd-disas.c | 2 +-
gdb/mi/mi-cmd-env.c | 16 ++---
gdb/mi/mi-cmd-file.c | 6 +-
gdb/mi/mi-cmd-info.c | 10 +--
gdb/mi/mi-cmd-stack.c | 18 +++---
gdb/mi/mi-cmd-target.c | 6 +-
gdb/mi/mi-cmd-var.c | 36 +++++------
gdb/mi/mi-cmds.h | 2 +-
gdb/mi/mi-interp.c | 2 +-
gdb/mi/mi-main.c | 86 +++++++++++++-------------
gdb/mi/mi-symbol-cmds.c | 2 +-
gdb/mips-tdep.c | 6 +-
gdb/mn10300-tdep.c | 10 +--
gdb/moxie-tdep.c | 2 +-
gdb/nat/linux-osdata.c | 6 +-
gdb/nto-tdep.c | 4 +-
gdb/nto-tdep.h | 2 +-
gdb/objc-lang.c | 8 +--
gdb/objc-lang.h | 7 ++-
gdb/objfiles.c | 2 +-
gdb/objfiles.h | 2 +-
gdb/obsd-nat.c | 2 +-
gdb/osdata.c | 13 +++-
gdb/osdata.h | 6 +-
gdb/p-exp.y | 6 +-
gdb/p-lang.h | 2 +-
gdb/parser-defs.h | 6 +-
gdb/printcmd.c | 2 +-
gdb/procfs.c | 4 +-
gdb/psymtab.c | 2 +-
gdb/python/py-arch.c | 2 +-
gdb/python/py-breakpoint.c | 8 +--
gdb/python/py-cmd.c | 16 ++---
gdb/python/py-event.c | 4 +-
gdb/python/py-event.h | 4 +-
gdb/python/py-evts.c | 2 +-
gdb/python/py-finishbreakpoint.c | 4 +-
gdb/python/py-framefilter.c | 2 +-
gdb/python/py-inferior.c | 11 ++--
gdb/python/py-objfile.c | 4 +-
gdb/python/py-param.c | 2 +-
gdb/python/py-symbol.c | 4 +-
gdb/python/py-type.c | 2 +-
gdb/python/py-unwind.c | 2 +-
gdb/python/py-value.c | 4 +-
gdb/python/python-internal.h | 120 ++++++++++++++++++++++++++++++++++++
gdb/python/python.c | 8 +--
gdb/ravenscar-thread.c | 8 +--
gdb/record-btrace.c | 8 +--
gdb/record-full.c | 2 +-
gdb/record.c | 14 ++---
gdb/remote-fileio.c | 2 +-
gdb/remote-sim.c | 2 +-
gdb/remote.c | 12 ++--
gdb/reverse.c | 2 +-
gdb/rs6000-tdep.c | 4 +-
gdb/rust-exp.y | 2 +-
gdb/rust-lang.c | 2 +-
gdb/rust-lang.h | 2 +-
gdb/serial.h | 2 +-
gdb/sh-tdep.c | 22 +++----
gdb/sh64-tdep.c | 2 +-
gdb/sol-thread.c | 2 +-
gdb/sol2-tdep.c | 2 +-
gdb/sol2-tdep.h | 2 +-
gdb/solib-darwin.c | 2 +-
gdb/spu-tdep.c | 4 +-
gdb/stabsread.c | 129 ++++++++++++++++++++-------------------
gdb/stabsread.h | 10 +--
gdb/symfile.c | 12 ++--
gdb/symfile.h | 2 +-
gdb/target-delegates.c | 18 +++---
gdb/target-descriptions.c | 8 ++-
gdb/target.c | 18 +++---
gdb/target.h | 11 ++--
gdb/thread.c | 2 +-
gdb/top.c | 7 ++-
gdb/top.h | 2 +-
gdb/tracefile-tfile.c | 4 +-
gdb/tracepoint.c | 24 +++++---
gdb/tracepoint.h | 2 +-
gdb/tui/tui-data.c | 2 +-
gdb/tui/tui-data.h | 2 +-
gdb/tui/tui-source.c | 2 +-
gdb/tui/tui-source.h | 2 +-
gdb/tui/tui-win.c | 11 ++--
gdb/tui/tui-windata.c | 2 +-
gdb/tui/tui-windata.h | 2 +-
gdb/tui/tui-winsource.c | 2 +-
gdb/tui/tui.c | 2 +-
gdb/utils.c | 13 ++--
gdb/utils.h | 4 +-
gdb/varobj.c | 2 +-
gdb/varobj.h | 2 +-
gdb/vax-tdep.c | 2 +-
gdb/warning.m4 | 2 +-
gdb/windows-nat.c | 4 +-
gdb/xcoffread.c | 8 +--
gdb/xml-support.c | 10 +--
gdb/xml-tdesc.c | 3 +-
gdb/xstormy16-tdep.c | 2 +-
gdb/xtensa-tdep.c | 2 +-
gdb/xtensa-tdep.h | 2 +-
include/dis-asm.h | 8 +--
opcodes/arc-dis.c | 4 +-
opcodes/arm-dis.c | 4 +-
opcodes/ppc-dis.c | 2 +-
opcodes/vax-dis.c | 2 +-
210 files changed, 983 insertions(+), 763 deletions(-)
--
2.5.5
next reply other threads:[~2017-04-04 17:25 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-04 17:25 Pedro Alves [this message]
2017-04-04 17:26 ` [PATCH 08/18] -Wwrite-strings: Constify mi_cmd_argv_ftype's 'command' parameter Pedro Alves
2017-04-04 17:26 ` [PATCH 14/18] -Wwrite-strings: Add a PyArg_ParseTupleAndKeywords "const char *" overload Pedro Alves
2017-04-04 18:37 ` Sergio Durigan Junior
2017-04-05 12:58 ` Pedro Alves
2017-04-05 15:49 ` Sergio Durigan Junior
2017-04-04 17:26 ` [PATCH 01/18] -Wwrite-strings: Constify struct disassemble_info's disassembler_options field Pedro Alves
2017-04-05 7:22 ` Nick Clifton
2017-04-04 17:26 ` [PATCH 02/18] -Wwrite-strings: Constify macroexp.c:init_shared_buffer Pedro Alves
2017-04-04 17:26 ` [PATCH 05/18] -Wwrite-strings: Constify warning_pre_print Pedro Alves
2017-04-04 17:26 ` [PATCH 04/18] -Wwrite-strings: Constify shell_escape and plug make_command leak Pedro Alves
2017-04-04 17:26 ` [PATCH 03/18] -Wwrite-strings: Don't initialize string command variables to empty string Pedro Alves
2017-04-04 17:26 ` [PATCH 06/18] -Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info Pedro Alves
2017-04-04 18:44 ` John Baldwin
2017-04-04 17:26 ` [PATCH 07/18] -Wwrite-strings: Constify work break character arrays Pedro Alves
2017-04-05 8:46 ` Philipp Rudo
2017-04-05 13:17 ` Pedro Alves
2017-04-04 17:26 ` [PATCH 09/18] -Wwrite-strings: MI -info-os Pedro Alves
2017-04-04 17:26 ` [PATCH 16/18] -Wwrite-strings: Some constification in gdb/breakpoint.c Pedro Alves
2017-04-04 17:26 ` [PATCH 15/18] -Wwrite-strings: execute_command calls with string literals Pedro Alves
2017-04-05 7:13 ` Metzger, Markus T
2017-04-05 13:10 ` Pedro Alves
2017-04-04 17:31 ` [PATCH 10/18] -Wwrite-strings: gdbserver's 'port' parsing Pedro Alves
2017-04-04 17:32 ` [PATCH 18/18] -Wwrite-strings: Remove -Wno-write-strings Pedro Alves
2019-02-14 16:17 ` Thomas Schwinge
2017-04-04 17:32 ` [PATCH 13/18] -Wwrite-strings: Wrap PyGetSetDef for construction with string literals Pedro Alves
2017-04-04 18:40 ` Sergio Durigan Junior
2017-04-05 12:35 ` Pedro Alves
2017-04-05 15:48 ` Sergio Durigan Junior
2017-04-05 8:49 ` Philipp Rudo
2017-04-05 13:03 ` Pedro Alves
2017-04-04 17:32 ` [PATCH 11/18] -Wwrite-strings: gdbserver/win32-low.c and TARGET_WAITKIND_EXECD Pedro Alves
2017-04-04 17:33 ` [PATCH 12/18] -Wwrite-strings: More fix-old-Python-API wrappers Pedro Alves
2017-04-04 17:36 ` [PATCH 17/18] -Wwrite-strings: The Rest Pedro Alves
2017-04-04 18:44 ` John Baldwin
2017-04-05 12:59 ` Pedro Alves
2017-04-04 18:42 ` [PATCH 00/18] gdb: Enable -Wwrite-strings (aka remove -Wno-write-strings) Sergio Durigan Junior
2017-04-04 19:37 ` Simon Marchi
2017-04-05 18:05 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1491326751-16180-1-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).