]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove call to reset from compile_to_object
authorTom Tromey <tom@tromey.com>
Sun, 24 Jan 2021 00:48:32 +0000 (17:48 -0700)
committerTom Tromey <tom@tromey.com>
Sun, 24 Jan 2021 00:48:48 +0000 (17:48 -0700)
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<char> itself.

2021-01-23  Tom Tromey  <tom@tromey.com>

* compile/compile-internal.h (class compile_instance)
<set_arguments>: Change return type.
* compile/compile.c (compile_to_object): Remove call to reset.
(compile_instance::set_arguments): Change return type.

gdb/ChangeLog
gdb/compile/compile-internal.h
gdb/compile/compile.c

index c1eedea35d79aa5686f91e28d8df3c87cd9b1717..a45957b55a118d02926b9174458f41b4d047052c 100644 (file)
@@ -1,3 +1,10 @@
+2021-01-23  Tom Tromey  <tom@tromey.com>
+
+       * compile/compile-internal.h (class compile_instance)
+       <set_arguments>: 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  <simon.marchi@polymtl.ca>
 
        * gdbtypes.c (copy_type_recursive): Use get_type_arch.
index dbded024081a27d3f5c3d788922fd1d06979e6c6..49ddbd42c83dcc6a80645c4a412b28d588779ec6 100644 (file)
@@ -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<char> 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);
index 074a865f9cc584272f999d48e75fadba1eb8a625..4e72adc943deb237de53a94d1be4fdd26b608170 100644 (file)
@@ -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<char> error_message;
-  error_message.reset (compiler->set_arguments (argc, argv,
-                                               triplet_rx.c_str ()));
+  gdb::unique_xmalloc_ptr<char> 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<char>
 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<char> (FORWARD (set_arguments, argc, argv));
   else
-    return FORWARD (set_arguments_v0, regexp, argc, argv);
+    return gdb::unique_xmalloc_ptr<char> (FORWARD (set_arguments_v0, regexp,
+                                                  argc, argv));
 }
 
 /* See compile-internal.h.  */