From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35820 invoked by alias); 6 Mar 2019 21:17:09 -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 35567 invoked by uid 89); 6 Mar 2019 21:17:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=BAYES_00,DNS_FROM_AHBL_RHSBL,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.1 spammy=HX-Spam-Relays-External:2001 X-HELO: mail-wr1-f68.google.com Received: from mail-wr1-f68.google.com (HELO mail-wr1-f68.google.com) (209.85.221.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Mar 2019 21:16:58 +0000 Received: by mail-wr1-f68.google.com with SMTP id w6so15039631wrs.4 for ; Wed, 06 Mar 2019 13:16:58 -0800 (PST) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4c97:6d52:2cea:997b? ([2001:8a0:f913:f700:4c97:6d52:2cea:997b]) by smtp.gmail.com with ESMTPSA id r6sm3672329wrx.48.2019.03.06.13.16.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Mar 2019 13:16:56 -0800 (PST) Subject: Re: [PATCH v2 11/22] Use unique_xmalloc_ptr in remote.c To: Tom Tromey , gdb-patches@sourceware.org References: <20190227201849.32210-1-tom@tromey.com> <20190227201849.32210-12-tom@tromey.com> From: Pedro Alves Message-ID: Date: Wed, 06 Mar 2019 21:17:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190227201849.32210-12-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-03/txt/msg00126.txt.bz2 On 02/27/2019 08:18 PM, Tom Tromey wrote: > This removes a cleanup from remote.c, replacing it with > unique_xmalloc_ptr. > > gdb/ChangeLog > 2019-02-27 Tom Tromey > > * remote.c (remote_target::remote_parse_stop_reply): Use > unique_xmalloc_ptr. > --- > gdb/ChangeLog | 5 +++++ > gdb/remote.c | 11 +++++------ > 2 files changed, 10 insertions(+), 6 deletions(-) > > diff --git a/gdb/remote.c b/gdb/remote.c > index f80dcdaee94..5f658deefaa 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -7314,14 +7314,13 @@ Packet: '%s'\n"), > > /* Save the pathname for event reporting and for > the next run command. */ > - char *pathname = (char *) xmalloc (pathlen + 1); > - struct cleanup *old_chain = make_cleanup (xfree, pathname); > - hex2bin (p1, (gdb_byte *) pathname, pathlen); > - pathname[pathlen] = '\0'; > - discard_cleanups (old_chain); > + gdb::unique_xmalloc_ptr pathname > + ((char *) xmalloc (pathlen + 1)); Use: gdb::unique_xmalloc_ptr > + hex2bin (p1, (gdb_byte *) pathname.get (), pathlen); > + pathname.get ()[pathlen] = '\0'; Then here write: pathname[pathlen] = '\0'; Otherwise OK. Thanks, Pedro Alves