[1/2] linux-nat: Remove unnecessary xstrdup

Message ID 1514732385-5506-1-git-send-email-simon.marchi@ericsson.com
State New, archived
Headers

Commit Message

Simon Marchi Dec. 31, 2017, 2:59 p.m. UTC
  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(-)
  

Comments

Pedro Alves Jan. 17, 2018, 12:25 p.m. UTC | #1
On 12/31/2017 02:59 PM, Simon Marchi wrote:
> 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.

LGTM.

Thanks,
Pedro Alves
  
Simon Marchi Jan. 17, 2018, 5:36 p.m. UTC | #2
On 2018-01-17 07:25, Pedro Alves wrote:
> On 12/31/2017 02:59 PM, Simon Marchi wrote:
>> 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.
> 
> LGTM.
> 
> Thanks,
> Pedro Alves

Thanks, I pushed both patches.

Simon
  

Patch

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