All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/3] block: Drop some superfluous casts from void *
Date: Mon, 02 Jun 2014 07:25:54 +0200	[thread overview]
Message-ID: <87ioojevbx.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <5388CEC7.9010607@redhat.com> (Max Reitz's message of "Fri, 30 May 2014 20:32:39 +0200")

Max Reitz <mreitz@redhat.com> writes:

> 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 <armbru@redhat.com>
>> ---
>>   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...

Fixes for that tend to involve back-and-forth type casting.  I find that
cure not much of an improvement over the disease :)

> Anyway:
>
> Reviewed-by: Max Reitz <mreitz@redhat.com>

Thanks!

       reply	other threads:[~2014-06-02  5:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1401467438-17189-1-git-send-email-armbru@redhat.com>
     [not found] ` <1401467438-17189-4-git-send-email-armbru@redhat.com>
     [not found]   ` <5388CEC7.9010607@redhat.com>
2014-06-02  5:25     ` Markus Armbruster [this message]
2014-07-01  9:06 ` [Qemu-devel] [PATCH 0/3] block: Use g_new() & friends more Markus Armbruster
2014-07-01 10:14   ` Kevin Wolf
2014-07-01 10:57     ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ioojevbx.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.