From: Tom Tromey Date: Sun, 24 Jan 2021 00:48:32 +0000 (-0700) Subject: Remove call to reset from compile_to_object X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9f7f6cb8d2cf1f356aab2a260baaa537de24d00b;p=binutils-gdb.git Remove call to reset from compile_to_object compile_to_object declares 'error_message' and then immediately calls reset on it. It seemed better to change it to use initialization instead; and then I noticed that set_arguments could return a unique_xmalloc_ptr itself. 2021-01-23 Tom Tromey * compile/compile-internal.h (class compile_instance) : Change return type. * compile/compile.c (compile_to_object): Remove call to reset. (compile_instance::set_arguments): Change return type. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c1eedea35d7..a45957b55a1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2021-01-23 Tom Tromey + + * compile/compile-internal.h (class compile_instance) + : Change return type. + * compile/compile.c (compile_to_object): Remove call to reset. + (compile_instance::set_arguments): Change return type. + 2021-01-23 Simon Marchi * gdbtypes.c (copy_type_recursive): Use get_type_arch. diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h index dbded024081..49ddbd42c83 100644 --- a/gdb/compile/compile-internal.h +++ b/gdb/compile/compile-internal.h @@ -96,7 +96,8 @@ public: /* Set compilation arguments. REGEXP is only used for protocol version GCC_FE_VERSION_0. */ - char *set_arguments (int argc, char **argv, const char *regexp = NULL); + gdb::unique_xmalloc_ptr set_arguments (int argc, char **argv, + const char *regexp = NULL); /* Set the filename of the program to compile. Nop for GCC_FE_VERSION_0. */ void set_source_file (const char *filename); diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 074a865f9cc..4e72adc943d 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -714,9 +714,8 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, int argc = argv_holder.count (); char **argv = argv_holder.get (); - gdb::unique_xmalloc_ptr error_message; - error_message.reset (compiler->set_arguments (argc, argv, - triplet_rx.c_str ())); + gdb::unique_xmalloc_ptr error_message + = compiler->set_arguments (argc, argv, triplet_rx.c_str ()); if (error_message != NULL) error ("%s", error_message.get ()); @@ -882,13 +881,14 @@ compile_instance::set_triplet_regexp (const char *regexp) /* See compile-internal.h. */ -char * +gdb::unique_xmalloc_ptr compile_instance::set_arguments (int argc, char **argv, const char *regexp) { if (version () >= GCC_FE_VERSION_1) - return FORWARD (set_arguments, argc, argv); + return gdb::unique_xmalloc_ptr (FORWARD (set_arguments, argc, argv)); else - return FORWARD (set_arguments_v0, regexp, argc, argv); + return gdb::unique_xmalloc_ptr (FORWARD (set_arguments_v0, regexp, + argc, argv)); } /* See compile-internal.h. */