public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH 1/2] linux-nat: Remove unnecessary xstrdup
Date: Sun, 31 Dec 2017 15:00:00 -0000	[thread overview]
Message-ID: <1514732385-5506-1-git-send-email-simon.marchi@ericsson.com> (raw)

I think this xstrdup is not useful.  We can pass ex.message directly to
throw_error instead.

gdb/ChangeLog:

	* linux-nat.c (linux_nat_attach): Remove xstrdup.
---
 gdb/linux-nat.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index b8f3108..1d1d6d3 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1224,10 +1224,7 @@ linux_nat_attach (struct target_ops *ops, const char *args, int from_tty)
     {
       pid_t pid = parse_pid_to_attach (args);
       struct buffer buffer;
-      char *message, *buffer_s;
-
-      message = xstrdup (ex.message);
-      make_cleanup (xfree, message);
+      char *buffer_s;
 
       buffer_init (&buffer);
       linux_ptrace_attach_fail_reason (pid, &buffer);
@@ -1237,9 +1234,9 @@ linux_nat_attach (struct target_ops *ops, const char *args, int from_tty)
       make_cleanup (xfree, buffer_s);
 
       if (*buffer_s != '\0')
-	throw_error (ex.error, "warning: %s\n%s", buffer_s, message);
+	throw_error (ex.error, "warning: %s\n%s", buffer_s, ex.message);
       else
-	throw_error (ex.error, "%s", message);
+	throw_error (ex.error, "%s", ex.message);
     }
   END_CATCH
 
-- 
2.7.4

             reply	other threads:[~2017-12-31 15:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-31 15:00 Simon Marchi [this message]
2017-12-31 15:00 ` [PATCH 2/2] Make linux_ptrace_attach_fail_reason return an std::string Simon Marchi
2018-01-17 12:26   ` Pedro Alves
2018-01-17 12:25 ` [PATCH 1/2] linux-nat: Remove unnecessary xstrdup Pedro Alves
2018-01-17 17:36   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1514732385-5506-1-git-send-email-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).