From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98698 invoked by alias); 16 Oct 2017 03:04:41 -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 98598 invoked by uid 89); 16 Oct 2017 03:04:40 -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,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1614 X-HELO: outbound-ss-1812.hostmonster.com Received: from gproxy1-pub.mail.unifiedlayer.com (HELO outbound-ss-1812.hostmonster.com) (69.89.25.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Oct 2017 03:04:39 +0000 Received: from cmgw3 (cmgw4 [10.0.90.84]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id D97D5175B73 for ; Sun, 15 Oct 2017 21:04:37 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id N34a1w00r2f2jeq0134dNu; Sun, 15 Oct 2017 21:04:37 -0600 X-Authority-Analysis: v=2.2 cv=H76r+6Qi c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=02M-m0pO-4AA:10 a=zstS-IiYAAAA:8 a=soSBNmY7FLf69a2y8u8A:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 184-96-33-178.hlrn.qwest.net ([184.96.33.178]:40598 helo=bapiya.localdomain) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1e3vhi-003iPW-MU; Sun, 15 Oct 2017 21:04:34 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 3/6] Remove cleanup from ppc-linux-nat.c Date: Mon, 16 Oct 2017 03:04:00 -0000 Message-Id: <20171016030427.21349-4-tom@tromey.com> In-Reply-To: <20171016030427.21349-1-tom@tromey.com> References: <20171016030427.21349-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1e3vhi-003iPW-MU X-Source-Sender: 184-96-33-178.hlrn.qwest.net (bapiya.localdomain) [184.96.33.178]:40598 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes X-SW-Source: 2017-10/txt/msg00404.txt.bz2 This removes a cleanup from ppc-linux-nat.c, by using unique_xmalloc_ptr. It also slightly simplifies the code by using XDUP rather than XNEW and memcpy. ChangeLog 2017-10-15 Tom Tromey * ppc-linux-nat.c (hwdebug_insert_point): Use gdb::unique_xmalloc_ptr, XDUP. --- gdb/ChangeLog | 5 +++++ gdb/ppc-linux-nat.c | 11 +++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 45c8903ef6..7c8ab6c67b 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -1541,16 +1541,13 @@ hwdebug_insert_point (struct ppc_hw_breakpoint *b, int tid) { int i; long slot; - struct ppc_hw_breakpoint *p = XNEW (struct ppc_hw_breakpoint); + gdb::unique_xmalloc_ptr p (XDUP (ppc_hw_breakpoint, b)); struct hw_break_tuple *hw_breaks; - struct cleanup *c = make_cleanup (xfree, p); struct thread_points *t; struct hw_break_tuple *tuple; - memcpy (p, b, sizeof (struct ppc_hw_breakpoint)); - errno = 0; - slot = ptrace (PPC_PTRACE_SETHWDEBUG, tid, 0, p); + slot = ptrace (PPC_PTRACE_SETHWDEBUG, tid, 0, p.get ()); if (slot < 0) perror_with_name (_("Unexpected error setting breakpoint or watchpoint")); @@ -1564,13 +1561,11 @@ hwdebug_insert_point (struct ppc_hw_breakpoint *b, int tid) if (hw_breaks[i].hw_break == NULL) { hw_breaks[i].slot = slot; - hw_breaks[i].hw_break = p; + hw_breaks[i].hw_break = p.release (); break; } gdb_assert (i != max_slots_number); - - discard_cleanups (c); } /* This function is a generic wrapper that is responsible for removing a -- 2.13.6