Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 6/8] Use std::string in ctf_start
Date: Sun, 10 Sep 2017 21:50:00 -0000	[thread overview]
Message-ID: <20170910215037.24329-7-tom@tromey.com> (raw)
In-Reply-To: <20170910215037.24329-1-tom@tromey.com>

This changes ctf_start to use std::string, allowing for some cleanup
removal.

ChangeLog
2017-09-10  Tom Tromey  <tom@tromey.com>

	* ctf.c (ctf_start): Use std::string.
---
 gdb/ChangeLog |  4 ++++
 gdb/ctf.c     | 18 ++++++------------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fe99b47..735de68 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2017-09-10  Tom Tromey  <tom@tromey.com>
 
+	* ctf.c (ctf_start): Use std::string.
+
+2017-09-10  Tom Tromey  <tom@tromey.com>
+
 	* ada-lang.c (is_known_support_routine): Update.
 	(ada_unhandled_exception_name_addr_from_raise): Update.
 	* guile/scm-frame.c (gdbscm_frame_name): Update.
diff --git a/gdb/ctf.c b/gdb/ctf.c
index 46a1bb5..d719163 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -311,8 +311,6 @@ ctf_target_save (struct trace_file_writer *self,
 static void
 ctf_start (struct trace_file_writer *self, const char *dirname)
 {
-  char *file_name;
-  struct cleanup *old_chain;
   struct ctf_trace_file_writer *writer
     = (struct ctf_trace_file_writer *) self;
   int i;
@@ -325,24 +323,20 @@ ctf_start (struct trace_file_writer *self, const char *dirname)
 
   memset (&writer->tcs, '\0', sizeof (writer->tcs));
 
-  file_name = xstrprintf ("%s/%s", dirname, CTF_METADATA_NAME);
-  old_chain = make_cleanup (xfree, file_name);
+  std::string file_name = string_printf ("%s/%s", dirname, CTF_METADATA_NAME);
 
-  writer->tcs.metadata_fd = fopen (file_name, "w");
+  writer->tcs.metadata_fd = fopen (file_name.c_str (), "w");
   if (writer->tcs.metadata_fd == NULL)
     error (_("Unable to open file '%s' for saving trace data (%s)"),
-	   file_name, safe_strerror (errno));
-  do_cleanups (old_chain);
+	   file_name.c_str (), safe_strerror (errno));
 
   ctf_save_metadata_header (&writer->tcs);
 
-  file_name = xstrprintf ("%s/%s", dirname, CTF_DATASTREAM_NAME);
-  old_chain = make_cleanup (xfree, file_name);
-  writer->tcs.datastream_fd = fopen (file_name, "w");
+  file_name = string_printf ("%s/%s", dirname, CTF_DATASTREAM_NAME);
+  writer->tcs.datastream_fd = fopen (file_name.c_str (), "w");
   if (writer->tcs.datastream_fd == NULL)
     error (_("Unable to open file '%s' for saving trace data (%s)"),
-	   file_name, safe_strerror (errno));
-  do_cleanups (old_chain);
+	   file_name.c_str (), safe_strerror (errno));
 }
 
 /* This is the implementation of trace_file_write_ops method
-- 
2.9.4


  parent reply	other threads:[~2017-09-10 21:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-10 21:50 [RFA 0/8] various cleanup removals Tom Tromey
2017-09-10 21:50 ` [RFA 4/8] Remove cleanups from findcmd.c Tom Tromey
2017-09-10 21:50 ` [RFA 5/8] Remove cleanups from find_frame_funname Tom Tromey
2017-09-11 20:25   ` Simon Marchi
2017-09-10 21:50 ` [RFA 2/8] Replace interp_set_temp with scoped_restore_interp Tom Tromey
2017-09-10 21:50 ` [RFA 7/8] Use std::string in d-namespace.c Tom Tromey
2017-09-10 21:50 ` Tom Tromey [this message]
2017-09-10 21:50 ` [RFA 1/8] Change setup_breakpoint_reporting to return a scoped_restore Tom Tromey
2017-09-10 21:50 ` [RFA 8/8] Remove make_show_memory_breakpoints_cleanup Tom Tromey
2017-09-11 20:34   ` Simon Marchi
2017-09-10 21:50 ` [RFA 3/8] Replace clear_hook_in_cleanup with scoped_restore_hook_in Tom Tromey
2017-09-11 20:35 ` [RFA 0/8] various cleanup removals Simon Marchi
2017-09-11 22:04   ` Tom Tromey

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=20170910215037.24329-7-tom@tromey.com \
    --to=tom@tromey.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