[Libguestfs] [PATCH libguestfs 4/8] build: don't perform arithmetic on void* pointers

Richard W.M. Jones rjones at redhat.com
Tue Aug 18 13:54:02 UTC 2009


On Tue, Aug 18, 2009 at 03:49:41PM +0200, Jim Meyering wrote:
> From: Jim Meyering <meyering at redhat.com>
> 
> * src/guestfs.c (receive_file_data_sync, xread, xwrite): Use char*.
> ---
>  src/guestfs.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/guestfs.c b/src/guestfs.c
> index 1cd4f9e..6eae692 100644
> --- a/src/guestfs.c
> +++ b/src/guestfs.c
> @@ -540,8 +540,9 @@ guestfs_safe_memdup (guestfs_h *g, void *ptr, size_t size)
>  }
> 
>  static int
> -xwrite (int fd, const void *buf, size_t len)
> +xwrite (int fd, const void *v_buf, size_t len)
>  {
> +  const char *buf = v_buf;
>    int r;
> 
>    while (len > 0) {
> @@ -557,8 +558,9 @@ xwrite (int fd, const void *buf, size_t len)
>  }
> 
>  static int
> -xread (int fd, void *buf, size_t len)
> +xread (int fd, void *v_buf, size_t len)
>  {
> +  char *buf = v_buf;
>    int r;
> 
>    while (len > 0) {
> @@ -2515,7 +2517,7 @@ receive_file_data_sync (guestfs_h *g, void **buf, size_t *len_r)
> 
>      if (buf) {
>        *buf = safe_realloc (g, *buf, len + ctx.chunks[i].data.data_len);
> -      memcpy (*buf+len, ctx.chunks[i].data.data_val,
> +      memcpy (((char *)*buf)+len, ctx.chunks[i].data.data_val,
>                ctx.chunks[i].data.data_len);
>      }
>      len += ctx.chunks[i].data.data_len;
> -- 
> 1.6.4.378.g88f2f

ACK.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html




More information about the Libguestfs mailing list