qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 4/4] block: Drop some superfluous casts from


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v2 4/4] block: Drop some superfluous casts from void *
Date: Mon, 18 Aug 2014 18:58:04 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

On 18.08.2014 18:10, 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/vhdx-log.c    | 2 +-
  block/vvfat.c       | 8 ++++----
  hw/ide/microdrive.c | 2 +-
  3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index eb5c7a0..4267e60 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -923,7 +923,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));
      data_sector = buffer + (desc_sectors * VHDX_LOG_SECTOR_SIZE);
      data_tmp = data;

You could drop the parantheses here. Also, I still don't like void pointer arithmetic, but well... ;-)

Reviewed-by: Max Reitz <address@hidden>



reply via email to

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