aboutsummaryrefslogtreecommitdiff
path: root/gdb/main.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-04-05 19:21:34 +0100
committerPedro Alves <palves@redhat.com>2017-04-05 19:21:34 +0100
commit69bbf465237819bd7bf2a21a682d695273b3c8cb (patch)
tree3850a83c0de5799d95dd93a61bcbf38fca934407 /gdb/main.c
parentbe47f9e8180d7275b0e2b26998472e99be9a2d7b (diff)
downloadgdb-69bbf465237819bd7bf2a21a682d695273b3c8cb.zip
gdb-69bbf465237819bd7bf2a21a682d695273b3c8cb.tar.gz
gdb-69bbf465237819bd7bf2a21a682d695273b3c8cb.tar.bz2
-Wwrite-strings: Constify warning_pre_print
-Wwrite-strings flags a warning here: char *warning_pre_print = "\nwarning: "; gdb/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * main.c (captured_main_1): Use gdb::unique_xmalloc_ptr to manage the memory of the temporary warning_pre_print override. * utils.c (warning_pre_print): Constify. * utils.h (warning_pre_print): Constify.
Diffstat (limited to 'gdb/main.c')
-rw-r--r--gdb/main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gdb/main.c b/gdb/main.c
index 30e27c2..df4b111 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -545,7 +545,9 @@ captured_main_1 (struct captured_main_args *context)
#endif
/* Prefix warning messages with the command name. */
- warning_pre_print = xstrprintf ("%s: warning: ", gdb_program_name);
+ gdb::unique_xmalloc_ptr<char> tmp_warn_preprint
+ (xstrprintf ("%s: warning: ", gdb_program_name));
+ warning_pre_print = tmp_warn_preprint.get ();
if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)))
perror_warning_with_name (_("error finding working directory"));
@@ -972,7 +974,7 @@ captured_main_1 (struct captured_main_args *context)
}
/* Set off error and warning messages with a blank line. */
- xfree (warning_pre_print);
+ tmp_warn_preprint.reset ();
warning_pre_print = _("\nwarning: ");
/* Read and execute the system-wide gdbinit file, if it exists.