This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] -Wwrite-strings: Don't initialize string command variables to empty string


*** TEST RESULTS FOR COMMIT bde6261aed330cd8d108c387bfe659a6171525dd ***

Author: Pedro Alves <palves@redhat.com>
Branch: master
Commit: bde6261aed330cd8d108c387bfe659a6171525dd

-Wwrite-strings: Don't initialize string command variables to empty string

-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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]