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

Jim Meyering jim at meyering.net
Tue Aug 18 13:49:41 UTC 2009


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




More information about the Libguestfs mailing list