From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96884 invoked by alias); 8 Sep 2019 19:30:49 -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 96868 invoked by uid 89); 8 Sep 2019 19:30:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=stuck, devices, device X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Sep 2019 19:30:44 +0000 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC27885550 for ; Sun, 8 Sep 2019 19:30:42 +0000 (UTC) Received: by mail-wr1-f69.google.com with SMTP id h6so3458819wrh.6 for ; Sun, 08 Sep 2019 12:30:42 -0700 (PDT) Received: from ?IPv6:2001:8a0:f913:f700:56ee:75ff:fe8d:232b? ([2001:8a0:f913:f700:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id y14sm23220015wrd.84.2019.09.08.12.30.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Sep 2019 12:30:40 -0700 (PDT) Subject: Re: [PATCH 20/23] Revert 'Remove unused struct serial::name field' To: Christian Biesinger References: <20190906232807.6191-1-palves@redhat.com> <20190906232807.6191-21-palves@redhat.com> Cc: gdb-patches From: Pedro Alves Message-ID: Date: Sun, 08 Sep 2019 19:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-09/txt/msg00123.txt.bz2 On 9/7/19 12:47 AM, Christian Biesinger via gdb-patches wrote: > Have you considered making this an std::string to avoid needing the manual > xfree? > struct serial hasn't been C++fied yet, it is still allocated with malloc (XCNEW), so we can't use std::string without further changes. So I stuck with just reverting the original patch as is, thinking that a change to use std::string or something like that could be done along other C++ification changes. Thanks, Pedro Alves > On Fri, Sep 6, 2019, 18:29 Pedro Alves wrote: > >> This commit reverts: >> >> commit 5f5219fc34f7557296272230123a3837960a6f09 >> Author: Pedro Alves >> AuthorDate: Tue Apr 12 16:49:30 2016 +0100 >> >> Remove unused struct serial::name field >> >> The following patches will add uses for the field. >> >> gdb/ChangeLog: >> yyyy-mm-dd Pedro Alves >> >> Revert: >> 2016-04-12 Pedro Alves >> * serial.c (serial_open, serial_fdopen_ops, do_serial_close): >> Remove references to name. >> * serial.h (struct serial) : Delete. >> --- >> gdb/serial.c | 4 ++++ >> gdb/serial.h | 1 + >> 2 files changed, 5 insertions(+) >> >> diff --git a/gdb/serial.c b/gdb/serial.c >> index a881bbc97c..0ed3d37406 100644 >> --- a/gdb/serial.c >> +++ b/gdb/serial.c >> @@ -247,6 +247,7 @@ serial_open_ops_1 (const struct serial_ops *ops, const >> char *open_name) >> return NULL; >> } >> >> + scb->name = open_name != NULL ? xstrdup (open_name) : NULL; >> scb->next = scb_base; >> scb_base = scb; >> >> @@ -291,6 +292,7 @@ serial_fdopen_ops (const int fd, const struct >> serial_ops *ops) >> >> scb = new_serial (ops); >> >> + scb->name = NULL; >> scb->next = scb_base; >> scb_base = scb; >> >> @@ -330,6 +332,8 @@ do_serial_close (struct serial *scb, int really_close) >> if (really_close) >> scb->ops->close (scb); >> >> + xfree (scb->name); >> + >> /* For serial_is_open. */ >> scb->bufp = NULL; >> >> diff --git a/gdb/serial.h b/gdb/serial.h >> index b75b3666e7..d58ab660e9 100644 >> --- a/gdb/serial.h >> +++ b/gdb/serial.h >> @@ -240,6 +240,7 @@ struct serial >> buffer. -ve for sticky errors. */ >> unsigned char *bufp; /* Current byte */ >> unsigned char buf[BUFSIZ]; /* Da buffer itself */ >> + char *name; /* The name of the device or host >> */ >> struct serial *next; /* Pointer to the next `struct serial *' */ >> int debug_p; /* Trace this serial devices operation. */ >> int async_state; /* Async internal state. */ >> -- >> 2.14.5 >> >>