All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Eric Auger <eric.auger@linaro.org>
Cc: peter.maydell@linaro.org, alex.williamson@redhat.com,
	arei.gonglei@huawei.com, eric.auger@st.com,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] hw/vfio/platform: replace g_malloc0_n by g_malloc0
Date: Thu, 11 Jun 2015 13:11:14 +0200	[thread overview]
Message-ID: <87381ywld9.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <1434006867-19701-1-git-send-email-eric.auger@linaro.org> (Eric Auger's message of "Thu, 11 Jun 2015 08:14:27 +0100")

Eric Auger <eric.auger@linaro.org> writes:

> g_malloc0_n() is introduced since glib-2.24 while QEMU currently
> requires glib-2.22. This may cause a link error on some distributions.
>
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> ---
>  hw/vfio/platform.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
> index 35266a8..c0acc8b 100644
> --- a/hw/vfio/platform.c
> +++ b/hw/vfio/platform.c
> @@ -346,8 +346,7 @@ static int vfio_populate_device(VFIODevice *vbasedev)
>          return ret;
>      }
>  
> -    vdev->regions = g_malloc0_n(vbasedev->num_regions,
> -                                sizeof(VFIORegion *));
> +    vdev->regions = g_malloc0(vbasedev->num_regions * sizeof(VFIORegion *));
>  
>      for (i = 0; i < vbasedev->num_regions; i++) {
>          struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };

Please use g_new0(VFIORegion, vbasedev->num_regions) for extra
compile-time checking and integer overflow protection.  See commits
58889fe net: Use g_new() & friends where that makes obvious sense
3c55fe2 scsi: Use g_new() & friends where that makes obvious sense
ab3ad07 x86: Use g_new() & friends where that makes obvious sense
3ba235a block: Use g_new0() for a bit of extra type checking
e1cf558 util: Use g_new() & friends where that makes obvious sense
02c4f26 block: Use g_new() & friends to avoid multiplying sizes
5839e53 block: Use g_new() & friends where that makes obvious sense

      parent reply	other threads:[~2015-06-11 11:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11  7:14 [Qemu-devel] [PATCH] hw/vfio/platform: replace g_malloc0_n by g_malloc0 Eric Auger
2015-06-11  7:55 ` Gonglei
2015-06-11  8:46   ` Eric Auger
2015-06-11 11:11 ` Markus Armbruster [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=87381ywld9.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=eric.auger@linaro.org \
    --cc=eric.auger@st.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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.