This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH c++ 07/12] gdbscm_memory_port_write: use local variable to avoid adding casts
- From: Doug Evans <xdje42 at gmail dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: gdb-patches at sourceware dot org
- Date: Sun, 25 Oct 2015 22:28:11 -0700
- Subject: Re: [PATCH c++ 07/12] gdbscm_memory_port_write: use local variable to avoid adding casts
- Authentication-results: sourceware.org; auth=none
- References: <1445831204-16588-1-git-send-email-simon dot marchi at polymtl dot ca> <1445831204-16588-7-git-send-email-simon dot marchi at polymtl dot ca>
Simon Marchi <simon.marchi@polymtl.ca> 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