This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] gdbscm_memory_port_write: use local variable to avoid adding casts


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e0dd41e9671fffc957c3d8f41adcd52274319f4f

commit e0dd41e9671fffc957c3d8f41adcd52274319f4f
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Mon Oct 26 08:41:37 2015 -0400

    gdbscm_memory_port_write: use local variable to avoid adding casts
    
    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.

Diff:
---
 gdb/ChangeLog         | 5 +++++
 gdb/guile/scm-ports.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ecc286f..2fc3427 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2015-10-26  Simon Marchi  <simon.marchi@polymtl.ca>
 
+	* guile/scm-ports.c (gdbscm_memory_port_write): Declare new
+	"data" local variable and use it.
+
+2015-10-26  Simon Marchi  <simon.marchi@polymtl.ca>
+
 	* guile/scm-symbol.c (gdbscm_lookup_global_symbol): Add
 	domain_enum cast.
 	(gdbscm_lookup_symbol): Likewise.
diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c
index 90bdb39..10d7ee2 100644
--- a/gdb/guile/scm-ports.c
+++ b/gdb/guile/scm-ports.c
@@ -716,10 +716,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.  */
@@ -758,7 +759,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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]