qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/3] block: Drop some superfluous casts from voi


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH 3/3] block: Drop some superfluous casts from void *
Date: Fri, 30 May 2014 20:32:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 30.05.2014 18:30, Markus Armbruster wrote:
They clutter the code.  Unfortunately, I can't figure out how to make
Coccinelle drop all of them, so I have to settle for common special
cases:

     @@
     type T;
     T *pt;
     void *pv;
     @@
     - pt = (T *)pv;
     + pt = pv;
     @@
     type T;
     @@
     - (T *)
       (\(g_malloc\|g_malloc0\|g_realloc\|g_new\|g_new0\|g_renew\|
         g_try_malloc\|g_try_malloc0\|g_try_realloc\|
         g_try_new\|g_try_new0\|g_try_renew\)(...))

Signed-off-by: Markus Armbruster <address@hidden>
---
  block/sheepdog.c    | 2 +-
  block/vhdx-log.c    | 2 +-
  block/vvfat.c       | 8 ++++----
  hw/ide/microdrive.c | 2 +-
  4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 0709fd0..340bdf6 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2202,7 +2202,7 @@ static int sd_snapshot_create(BlockDriverState *bs, 
QEMUSnapshotInfo *sn_info)
          goto cleanup;
      }
- inode = (SheepdogInode *)g_malloc(datalen);
+    inode = g_malloc(datalen);
ret = read_object(fd, (char *)inode, vid_to_vdi_oid(new_vid),
                        s->inode.nr_copies, datalen, 0, s->cache_flags);
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 3eb7e68..f07328d 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -909,7 +909,7 @@ static int vhdx_log_write(BlockDriverState *bs, 
BDRVVHDXState *s,
      buffer = qemu_blockalign(bs, total_length);
      memcpy(buffer, &new_hdr, sizeof(new_hdr));
- new_desc = (VHDXLogDescriptor *) (buffer + sizeof(new_hdr));
+    new_desc = buffer + sizeof(new_hdr);

Perhaps we should try to fix void pointer arithmetic some time...

Anyway:

Reviewed-by: Max Reitz <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]