From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 2F4493851C0D for ; Thu, 25 Jun 2020 21:07:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2F4493851C0D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C1C6A1E792; Thu, 25 Jun 2020 17:07:14 -0400 (EDT) Subject: Re: [PATCH] gdb: make inferior::terminal a unique ptr To: Tom Tromey , Simon Marchi via Gdb-patches Cc: Simon Marchi References: <20200625155517.32173-1-simon.marchi@efficios.com> <87zh8qewbj.fsf@tromey.com> From: Simon Marchi Message-ID: Date: Thu, 25 Jun 2020 17:07:14 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <87zh8qewbj.fsf@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jun 2020 21:07:16 -0000 On 2020-06-25 4:15 p.m., Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi via Gdb-patches writes: > > Simon> - current_inferior ()->terminal = xstrdup (terminal_name); > Simon> + current_inferior ()->terminal.reset (xstrdup (terminal_name)); > > You can use make_unique_xstrdup and avoid the call to reset, in favor of > move assignment. > > Tom > Good catch. I pushed the following patch that does it. >From 58373b80f3d06740fccefe735fbb390791092027 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 25 Jun 2020 17:06:18 -0400 Subject: [PATCH] gdb: use make_unique_xstrdup in set_inferior_io_terminal gdb/ChangeLog: * infcmd.c (set_inferior_io_terminal): Use make_unique_xstrdup. Change-Id: I38b6e753f58947531fe4a293d574bc27ec128f47 --- gdb/ChangeLog | 4 ++++ gdb/infcmd.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d9b6a49bd105..ddb5c47d1e75 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2020-06-25 Simon Marchi + + * infcmd.c (set_inferior_io_terminal): Use make_unique_xstrdup. + 2020-06-25 Simon Marchi * inferior.h (struct inferior) : Change type to diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 48d6a91c0c24..17f7b9abeac3 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -109,7 +109,7 @@ void set_inferior_io_terminal (const char *terminal_name) { if (terminal_name != NULL && *terminal_name != '\0') - current_inferior ()->terminal.reset (xstrdup (terminal_name)); + current_inferior ()->terminal = make_unique_xstrdup (terminal_name); else current_inferior ()->terminal = NULL; } -- 2.26.2