From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2y7u-0007yA-Lc for qemu-devel@nongnu.org; Thu, 11 Jun 2015 04:46:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2y7r-0008GU-AN for qemu-devel@nongnu.org; Thu, 11 Jun 2015 04:46:18 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:34015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2y7r-0008Fx-3l for qemu-devel@nongnu.org; Thu, 11 Jun 2015 04:46:15 -0400 Received: by wgv5 with SMTP id 5so496975wgv.1 for ; Thu, 11 Jun 2015 01:46:14 -0700 (PDT) Message-ID: <55794AC8.20602@linaro.org> Date: Thu, 11 Jun 2015 10:46:00 +0200 From: Eric Auger MIME-Version: 1.0 References: <1434006867-19701-1-git-send-email-eric.auger@linaro.org> <55793F0C.3080403@huawei.com> In-Reply-To: <55793F0C.3080403@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] hw/vfio/platform: replace g_malloc0_n by g_malloc0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gonglei , eric.auger@st.com, qemu-devel@nongnu.org, alex.williamson@redhat.com, peter.maydell@linaro.org Hi Gonglei, On 06/11/2015 09:55 AM, Gonglei wrote: > On 2015/6/11 15:14, Eric Auger wrote: >> 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 >> --- >> 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 *)); >> > > Why not use g_new0() which returned pointer is cast to the given type? Looks relevant indeed. g_malloc0 is used in similar situations in rest of the VFIO code so I posted a new version and let Alex choose among both. Thanks Eric > > Regards, > -Gonglei >> for (i = 0; i < vbasedev->num_regions; i++) { >> struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) }; >> > >