From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPntw-0000Nw-EL for qemu-devel@nongnu.org; Thu, 22 Nov 2018 07:16:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPnmk-0007xx-Tl for qemu-devel@nongnu.org; Thu, 22 Nov 2018 07:08:46 -0500 References: <1542261954-4060-1-git-send-email-liq3ea@gmail.com> From: Laurent Vivier Message-ID: <815170fb-b014-23cd-f1ad-03969a7964e7@vivier.eu> Date: Thu, 22 Nov 2018 13:08:17 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , Li Qiang , rth@twiddle.net, ehabkost@redhat.com Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= On 21/11/2018 18:55, Paolo Bonzini wrote: > On 15/11/18 07:05, Li Qiang wrote: >> And also the g_malloc doesn't need check return value, >> remove it. >> >> Cc: qemu-trivial@nongnu.org >> >> Signed-off-by: Li Qiang >> --- >> target/i386/hax-all.c | 15 +++------------ >> 1 file changed, 3 insertions(+), 12 deletions(-) >> >> diff --git a/target/i386/hax-all.c b/target/i386/hax-all.c >> index d2e512856b..a460c605af 100644 >> --- a/target/i386/hax-all.c >> +++ b/target/i386/hax-all.c >> @@ -154,13 +154,7 @@ int hax_vcpu_create(int id) >> return 0; >> } >> >> - vcpu = g_malloc(sizeof(struct hax_vcpu_state)); >> - if (!vcpu) { >> - fprintf(stderr, "Failed to alloc vcpu state\n"); >> - return -ENOMEM; >> - } >> - >> - memset(vcpu, 0, sizeof(struct hax_vcpu_state)); >> + vcpu = g_malloc0(sizeof(struct hax_vcpu_state)); >> >> ret = hax_host_create_vcpu(hax_global.vm->fd, id); >> if (ret) { >> @@ -250,11 +244,8 @@ struct hax_vm *hax_vm_create(struct hax_state *hax) >> return hax->vm; >> } >> >> - vm = g_malloc(sizeof(struct hax_vm)); >> - if (!vm) { >> - return NULL; >> - } >> - memset(vm, 0, sizeof(struct hax_vm)); >> + vm = g_malloc0(sizeof(struct hax_vm)); >> + >> ret = hax_host_create_vm(hax, &vm_id); >> if (ret) { >> fprintf(stderr, "Failed to create vm %x\n", ret); >> > > Queued, thanks. Markus and Philippe have asked to use g_new0() rather than g_malloc0(). Thanks, Laurent