From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3713 invoked by alias); 26 Nov 2017 14:21:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 3704 invoked by uid 89); 26 Nov 2017 14:21:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:2074 X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 26 Nov 2017 14:21:39 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id vAQELV7w000506 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 26 Nov 2017 09:21:36 -0500 Received: by simark.ca (Postfix, from userid 112) id C97421E586; Sun, 26 Nov 2017 09:21:31 -0500 (EST) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 2C4A61E02D; Sun, 26 Nov 2017 09:21:20 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 26 Nov 2017 14:21:00 -0000 From: Simon Marchi To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Removes a cleanup from gcore.c In-Reply-To: <20171125211202.32118-1-tom@tromey.com> References: <20171125211202.32118-1-tom@tromey.com> Message-ID: <5420e22f83ee47b3b134d5edf21bf02c@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.2 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sun, 26 Nov 2017 14:21:32 +0000 X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg00661.txt.bz2 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 > > * 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 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, ¬e_size); > + note_data.reset (target_make_corefile_notes (obfd, ¬e_size)); > else > - note_data = gdbarch_make_corefile_notes (target_gdbarch (), obfd, > ¬e_size); > - > - cleanup = make_cleanup (xfree, note_data); > + note_data.reset (gdbarch_make_corefile_notes (target_gdbarch (), > obfd, > + ¬e_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.