]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbserver: cleanup in handle_v_run
authorAndrew Burgess <aburgess@redhat.com>
Wed, 27 Sep 2023 17:04:34 +0000 (18:04 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 6 Oct 2023 12:02:36 +0000 (13:02 +0100)
After the previous commit there is now a redundant string copy in
handle_v_run, this commit cleans that up.

There should be no functional change after this commit.

During review I was pointed to this older series:

  https://inbox.sourceware.org/gdb-patches/20211022071933.3478427-1-m.weghorn@posteo.de/

which also includes this fix as part of a larger set of changes.  I'm
giving a Co-Authored-By credit to the author of that original series.
I believe this smaller fix brings some benefits on its own, though the
original series does offer additional improvements.  Once this is
merged I'll take a look at rebasing and resubmitting the original series.

Co-Authored-By: Michael Weghorn <m.weghorn@posteo.de>
Approved-By: Tom Tromey <tom@tromey.com>
gdbserver/server.cc

index 84b8712e668fd18367345f15335ad1aec89c0acd..e02cdb83b51a91a3c1f76a7e4b69c7f1dd7b1fd1 100644 (file)
@@ -2989,33 +2989,19 @@ handle_v_run (char *own_buf)
        }
       else
        {
+         /* The length of the decoded argument.  */
          size_t len = (next_p - p) / 2;
-         /* ARG is the unquoted argument received via the RSP.  */
+
+         /* Buffer to decode the argument into.  */
          char *arg = (char *) xmalloc (len + 1);
-         /* FULL_ARGS will contain the quoted version of ARG.  */
-         char *full_arg = (char *) xmalloc ((len + 1) * 2);
-         /* These are pointers used to navigate the strings above.  */
-         char *tmp_arg = arg;
-         char *tmp_full_arg = full_arg;
 
          hex2bin (p, (gdb_byte *) arg, len);
          arg[len] = '\0';
 
-         while (*tmp_arg != '\0')
-           {
-             *tmp_full_arg = *tmp_arg;
-             ++tmp_full_arg;
-             ++tmp_arg;
-           }
-
-         /* Finish FULL_ARG and push it into the vector containing
-            the argv.  */
-         *tmp_full_arg = '\0';
          if (i == 0)
-           new_program_name = full_arg;
+           new_program_name = arg;
          else
-           new_argv.push_back (full_arg);
-         xfree (arg);
+           new_argv.push_back (arg);
        }
       if (*next_p == '\0')
        break;