aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/main.c6
-rw-r--r--gdb/utils.c2
-rw-r--r--gdb/utils.h2
4 files changed, 13 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 00f8d1c..f07927d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
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.
+
+2017-04-05 Pedro Alves <palves@redhat.com>
+
* cli/cli-cmds.c (shell_escape): Constify 'arg' parameter.
(shell_command): New function.
(make_command): Use std::string.
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.
diff --git a/gdb/utils.c b/gdb/utils.c
index 39798cc..6b8f2f7 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -122,7 +122,7 @@ show_sevenbit_strings (struct ui_file *file, int from_tty,
/* String to be printed before warning messages, if any. */
-char *warning_pre_print = "\nwarning: ";
+const char *warning_pre_print = "\nwarning: ";
int pagination_enabled = 1;
static void
diff --git a/gdb/utils.h b/gdb/utils.h
index fb75f2e..2380bd7 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -298,7 +298,7 @@ extern void (*deprecated_error_begin_hook) (void);
/* Message to be printed before the warning message, when a warning occurs. */
-extern char *warning_pre_print;
+extern const char *warning_pre_print;
extern void error_stream (const string_file &) ATTRIBUTE_NORETURN;