Received: from eggs.gnu.org ([2001:4830:134:3::10]:58087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJerp-0002lC-JX for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:34:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJeri-0001y4-RI for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:34:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJeri-0001wq-Eo for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:34:02 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7J8Y10Z014695 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Aug 2014 04:34:01 -0400 From: Markus Armbruster References: <1408378243-19713-1-git-send-email-armbru@redhat.com> <1408378243-19713-5-git-send-email-armbru@redhat.com> <20140818200646.GE2627@localhost.localdomain> <87siktar9d.fsf@blackfin.pond.sub.org> Date: Tue, 19 Aug 2014 10:33:58 +0200 In-Reply-To: <87siktar9d.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Tue, 19 Aug 2014 09:10:54 +0200") Message-ID: <877g247ua1.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 4/4] block: Drop some superfluous casts from void * List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com Markus Armbruster writes: > Jeff Cody writes: > >> On Mon, Aug 18, 2014 at 06:10:43PM +0200, 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/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)); >> >> Agree with Max, in that the parenthesis could be removed. Not worthy >> of a respin normally, but since the point of this patch is to >> unclutter the code, I guess it makes sense to fix it. > > Max and you are right. I neglected to clean up the patch produced by > spatch. Cleaned up in v3. >>> data_sector = buffer + (desc_sectors * VHDX_LOG_SECTOR_SIZE); >>> data_tmp = data; >>> >>> diff --git a/block/vvfat.c b/block/vvfat.c >>> index f877e85..401539d 100644 >>> --- a/block/vvfat.c >>> +++ b/block/vvfat.c >>> @@ -732,7 +732,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index) >>> if(first_cluster == 0 && (is_dotdot || is_dot)) >>> continue; >>> >>> - buffer=(char*)g_malloc(length); >>> + buffer=g_malloc(length); >> >> You missed a spot to put spaces around the '=' here. Nothing worthy >> of a respin, of course - just a note in case you decide to respin. > > Right again. Although perhaps vvfat should remain ugly, to warn unwary > travellers ;) Cleaned up in v3. [...]