From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60345 invoked by alias); 26 Oct 2015 05:29:30 -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 60333 invoked by uid 89); 26 Oct 2015 05:29:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f54.google.com Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 26 Oct 2015 05:29:28 +0000 Received: by padhk11 with SMTP id hk11so177141119pad.1 for ; Sun, 25 Oct 2015 22:29:27 -0700 (PDT) X-Received: by 10.67.12.166 with SMTP id er6mr38929593pad.40.1445837367086; Sun, 25 Oct 2015 22:29:27 -0700 (PDT) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by smtp.gmail.com with ESMTPSA id ve8sm31406423pbc.48.2015.10.25.22.29.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Oct 2015 22:29:26 -0700 (PDT) From: Doug Evans To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH c++ 07/12] gdbscm_memory_port_write: use local variable to avoid adding casts References: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> <1445831204-16588-7-git-send-email-simon.marchi@polymtl.ca> Date: Mon, 26 Oct 2015 12:55:00 -0000 In-Reply-To: <1445831204-16588-7-git-send-email-simon.marchi@polymtl.ca> (Simon Marchi's message of "Sun, 25 Oct 2015 23:46:39 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg00546.txt.bz2 Simon Marchi writes: > By having a local variable of type (const gdb_byte *), we can avoid adding > two casts. > > gdb/ChangeLog: > > * guile/scm-ports.c (gdbscm_memory_port_write): Declare new > "data" local variable and use it. > --- > gdb/guile/scm-ports.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c > index 49e4fd6..2cca889 100644 > --- a/gdb/guile/scm-ports.c > +++ b/gdb/guile/scm-ports.c > @@ -725,10 +725,11 @@ gdbscm_memory_port_flush (SCM port) > /* "write" method for memory ports. */ > > static void > -gdbscm_memory_port_write (SCM port, const void *data, size_t size) > +gdbscm_memory_port_write (SCM port, const void *void_data, size_t size) > { > scm_t_port *pt = SCM_PTAB_ENTRY (port); > ioscm_memory_port *iomem = (ioscm_memory_port *) SCM_STREAM (port); > + const gdb_byte *data = (const gdb_byte *) void_data; > > /* There's no way to indicate a short write, so if the request goes past > the end of the port's memory range, flag an error. */ > @@ -767,7 +768,7 @@ gdbscm_memory_port_write (SCM port, const void *data, size_t size) > pt->write_pos = pt->write_end; > gdbscm_memory_port_flush (port); > { > - const void *ptr = ((const char *) data) + space; > + const gdb_byte *ptr = data + space; > size_t remaining = size - space; > > if (remaining >= pt->write_buf_size) LGTM