Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Removes a cleanup from gcore.c
Date: Sun, 26 Nov 2017 14:21:00 -0000	[thread overview]
Message-ID: <5420e22f83ee47b3b134d5edf21bf02c@polymtl.ca> (raw)
In-Reply-To: <20171125211202.32118-1-tom@tromey.com>

On 2017-11-25 16:12, Tom Tromey wrote:
> This removes a cleanup from gcore.c, replacing it with
> unique_xmalloc_ptr.
> 
> Regression tested by the buildbot.
> 
> ChangeLog
> 2017-11-25  Tom Tromey  <tom@tromey.com>
> 
> 	* gcore.c (write_gcore_file_1): Use gdb::unique_xmalloc_ptr.
> ---
>  gdb/ChangeLog |  4 ++++
>  gdb/gcore.c   | 15 ++++++---------
>  2 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/gdb/gcore.c b/gdb/gcore.c
> index 0d5dccab61..359ec3df84 100644
> --- a/gdb/gcore.c
> +++ b/gdb/gcore.c
> @@ -68,8 +68,7 @@ create_gcore_bfd (const char *filename)
>  static void
>  write_gcore_file_1 (bfd *obfd)
>  {
> -  struct cleanup *cleanup;
> -  void *note_data = NULL;
> +  gdb::unique_xmalloc_ptr<char> note_data;
>    int note_size = 0;
>    asection *note_sec = NULL;
> 
> @@ -78,11 +77,10 @@ write_gcore_file_1 (bfd *obfd)
>       generation should be converted to gdbarch_make_corefile_notes; at 
> that
>       point, the target vector method can be removed.  */
>    if (!gdbarch_make_corefile_notes_p (target_gdbarch ()))
> -    note_data = target_make_corefile_notes (obfd, &note_size);
> +    note_data.reset (target_make_corefile_notes (obfd, &note_size));
>    else
> -    note_data = gdbarch_make_corefile_notes (target_gdbarch (), obfd,
> &note_size);
> -
> -  cleanup = make_cleanup (xfree, note_data);
> +    note_data.reset (gdbarch_make_corefile_notes (target_gdbarch (), 
> obfd,
> +						  &note_size));
> 
>    if (note_data == NULL || note_size == 0)
>      error (_("Target does not support core file generation."));
> @@ -105,10 +103,9 @@ write_gcore_file_1 (bfd *obfd)
>      error (_("gcore: failed to get corefile memory sections from 
> target."));
> 
>    /* Write out the contents of the note section.  */
> -  if (!bfd_set_section_contents (obfd, note_sec, note_data, 0, 
> note_size))
> +  if (!bfd_set_section_contents (obfd, note_sec, note_data.get (), 0,
> +				 note_size))
>      warning (_("writing note section (%s)"), bfd_errmsg (bfd_get_error 
> ()));
> -
> -  do_cleanups (cleanup);
>  }
> 
>  /* write_gcore_file -- helper for gcore_command (exported).

LGTM.


      reply	other threads:[~2017-11-26 14:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-25 21:12 Tom Tromey
2017-11-26 14:21 ` Simon Marchi [this message]

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=5420e22f83ee47b3b134d5edf21bf02c@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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