qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com,
	mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 4/4] block: Drop some superfluous casts from void *
Date: Mon, 18 Aug 2014 16:06:46 -0400	[thread overview]
Message-ID: <20140818200646.GE2627@localhost.localdomain> (raw)
In-Reply-To: <1408378243-19713-5-git-send-email-armbru@redhat.com>

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

>      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.


[...]

With or without the changes above:

Reviewed-by: Jeff Cody <jcody@redhat.com>

  parent reply	other threads:[~2014-08-18 20:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18 16:10 [Qemu-devel] [PATCH v2 0/4] block: Use g_new() & friends more Markus Armbruster
2014-08-18 16:10 ` [Qemu-devel] [PATCH v2 1/4] block: Use g_new() & friends where that makes obvious sense Markus Armbruster
2014-08-18 16:35   ` Max Reitz
2014-08-18 19:43   ` Jeff Cody
2014-08-18 16:10 ` [Qemu-devel] [PATCH v2 2/4] block: Use g_new() & friends to avoid multiplying sizes Markus Armbruster
2014-08-18 16:48   ` Max Reitz
2014-08-18 19:57   ` Jeff Cody
2014-08-18 16:10 ` [Qemu-devel] [PATCH v2 3/4] qemu-io-cmds: g_renew() can't fail, bury dead error handling Markus Armbruster
2014-08-18 16:50   ` Max Reitz
2014-08-18 19:59   ` Jeff Cody
2014-08-18 16:10 ` [Qemu-devel] [PATCH v2 4/4] block: Drop some superfluous casts from void * Markus Armbruster
2014-08-18 16:58   ` Max Reitz
2014-08-19  7:10     ` Markus Armbruster
2014-08-18 20:06   ` Jeff Cody [this message]
2014-08-19  7:10     ` Markus Armbruster
2014-08-19  8:33       ` 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=20140818200646.GE2627@localhost.localdomain \
    --to=jcody@redhat.com \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).