From patchwork Sat Nov 25 21:12:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 24532 Received: (qmail 32290 invoked by alias); 25 Nov 2017 21:12:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 32281 invoked by uid 89); 25 Nov 2017 21:12:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (50.116.124.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 25 Nov 2017 21:12:05 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 828FD400E11D8 for ; Sat, 25 Nov 2017 15:12:04 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id Ihk4eQzei5b6TIhk4ebpRC; Sat, 25 Nov 2017 15:12:04 -0600 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:48416 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eIhk4-002FGm-AP; Sat, 25 Nov 2017 15:12:04 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Removes a cleanup from gcore.c Date: Sat, 25 Nov 2017 14:12:02 -0700 Message-Id: <20171125211202.32118-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eIhk4-002FGm-AP X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya.Home) [71.218.90.63]:48416 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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).