-Wwrite-strings flags these initializations as requiring a cast.
However, these variables are command variables, and as such point to
heap-allocated memory. The initial allocation is always done when the
corresponding command is registered. E.g.,:
dprintf_function = xstrdup ("printf");
add_setshow_string_cmd ("dprintf-function", class_support,
&dprintf_function, _("\
Set the function to use for dynamic printf"), _("\
Show the function to use for dynamic printf"), NULL,
update_dprintf_commands, NULL,
&setlist, &showlist);
That's why we never reach a bogus attempt to free these string
literals.
So, just drop the incorrect initializations.
gdb/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* breakpoint.c (dprintf_function, dprintf_channel): Don't initialize.
* tracepoint.c (default_collect): Don't initialize.
2017-04-05 Pedro Alves <palves@redhat.com>
2017-04-05 Pedro Alves <palves@redhat.com>
+ * breakpoint.c (dprintf_function, dprintf_channel): Don't initialize.
+ * tracepoint.c (default_collect): Don't initialize.
+
+2017-04-05 Pedro Alves <palves@redhat.com>
+
* macroexp.c (macro_buffer::shared): Now a bool.
(init_buffer): Update.
(init_shared_buffer): Constify 'addr' parameter.
* macroexp.c (macro_buffer::shared): Now a bool.
(init_buffer): Update.
(init_shared_buffer): Constify 'addr' parameter.
copied into the command, so it can be anything that GDB can
evaluate to a callable address, not necessarily a function name. */
copied into the command, so it can be anything that GDB can
evaluate to a callable address, not necessarily a function name. */
-static char *dprintf_function = "";
+static char *dprintf_function;
/* The channel to use for dynamic printf if the preferred style is to
call into the inferior; if a nonempty string, it will be passed to
/* The channel to use for dynamic printf if the preferred style is to
call into the inferior; if a nonempty string, it will be passed to
"stderr", this could be an app-specific expression like
"mystreams[curlogger]". */
"stderr", this could be an app-specific expression like
"mystreams[curlogger]". */
-static char *dprintf_channel = "";
+static char *dprintf_channel;
/* True if dprintf commands should continue to operate even if GDB
has disconnected. */
/* True if dprintf commands should continue to operate even if GDB
has disconnected. */
static struct cmd_list_element *tfindlist;
/* List of expressions to collect by default at each tracepoint hit. */
static struct cmd_list_element *tfindlist;
/* List of expressions to collect by default at each tracepoint hit. */
-char *default_collect = "";
static int disconnected_tracing;
static int disconnected_tracing;