qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vdi: Fix warning from clang
Date: Tue, 04 Sep 2012 16:38:05 +0200	[thread overview]
Message-ID: <5046124D.4010409@redhat.com> (raw)
In-Reply-To: <1345209804-24632-1-git-send-email-sw@weilnetz.de>

Am 17.08.2012 15:23, schrieb Stefan Weil:
> ccc-analyzer reports these warnings:
> 
> block/vdi.c:704:13: warning: Dereference of null pointer
>             bmap[i] = VDI_UNALLOCATED;
>             ^
> block/vdi.c:702:13: warning: Dereference of null pointer
>             bmap[i] = i;
>             ^
> 
> Moving some code into the if block fixes this.
> It also avoids calling function write with 0 bytes of data.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  block/vdi.c |   25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/block/vdi.c b/block/vdi.c
> index c4f1529..d80114a 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -628,7 +628,6 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options)
>      VdiHeader header;
>      size_t i;
>      size_t bmap_size;
> -    uint32_t *bmap;
>  
>      logout("\n");
>  
> @@ -693,21 +692,21 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options)
>          result = -errno;
>      }
>  
> -    bmap = NULL;
>      if (bmap_size > 0) {
> -        bmap = (uint32_t *)g_malloc0(bmap_size);
> -    }
> -    for (i = 0; i < blocks; i++) {
> -        if (image_type == VDI_TYPE_STATIC) {
> -            bmap[i] = i;
> -        } else {
> -            bmap[i] = VDI_UNALLOCATED;
> +        uint32_t *bmap = (uint32_t *)g_malloc0(bmap_size);

Thanks. Removed the unnecessary cast and applied to block-next.

Kevin

      reply	other threads:[~2012-09-04 14:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-17 13:23 [Qemu-devel] [PATCH] vdi: Fix warning from clang Stefan Weil
2012-09-04 14:38 ` Kevin Wolf [this message]

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=5046124D.4010409@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /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).