From patchwork Mon Oct 26 03:46:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 9368 Received: (qmail 15069 invoked by alias); 26 Oct 2015 03:47:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14986 invoked by uid 89); 26 Oct 2015 03:47:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_05, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: smtp.electronicbox.net Received: from smtp.electronicbox.net (HELO smtp.electronicbox.net) (96.127.255.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Oct 2015 03:47:10 +0000 Received: from simark.lan. (cable-192.222.137.139.electronicbox.net [192.222.137.139]) by smtp.electronicbox.net (Postfix) with ESMTP id 14591440E84; Sun, 25 Oct 2015 23:47:09 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH c++ 07/12] gdbscm_memory_port_write: use local variable to avoid adding casts Date: Sun, 25 Oct 2015 23:46:39 -0400 Message-Id: <1445831204-16588-7-git-send-email-simon.marchi@polymtl.ca> In-Reply-To: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> References: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> 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)