From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrKlA-0007h1-Du for qemu-devel@nongnu.org; Mon, 02 Jun 2014 01:26:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrKl1-0007dc-Bj for qemu-devel@nongnu.org; Mon, 02 Jun 2014 01:26:12 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:201:233:1::3]:45919) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrKl1-0007cY-44 for qemu-devel@nongnu.org; Mon, 02 Jun 2014 01:26:03 -0400 Received: from blackfin.pond.sub.org (p5B329868.dip0.t-ipconnect.de [91.50.152.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by oxygen.pond.sub.org (Postfix) with ESMTPSA id B08E3261DA for ; Mon, 2 Jun 2014 07:25:55 +0200 (CEST) From: Markus Armbruster References: <1401467438-17189-1-git-send-email-armbru@redhat.com> <1401467438-17189-4-git-send-email-armbru@redhat.com> <5388CEC7.9010607@redhat.com> Date: Mon, 02 Jun 2014 07:25:54 +0200 In-Reply-To: <5388CEC7.9010607@redhat.com> (Max Reitz's message of "Fri, 30 May 2014 20:32:39 +0200") Message-ID: <87ioojevbx.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 3/3] block: Drop some superfluous casts from void * List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Max Reitz 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 >> --- >> 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 Thanks!