From nobody Thu Nov 6 16:15:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 154226897790572.56073430268907; Thu, 15 Nov 2018 00:02:57 -0800 (PST) Received: from localhost ([::1]:37285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNCbz-00057q-R0 for importer@patchew.org; Thu, 15 Nov 2018 03:02:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNApi-0007PH-TD for qemu-devel@nongnu.org; Thu, 15 Nov 2018 01:08:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNApe-0007Ho-WC for qemu-devel@nongnu.org; Thu, 15 Nov 2018 01:08:54 -0500 Received: from [123.58.160.154] (port=4685 helo=localhost.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNApe-0007H7-2g; Thu, 15 Nov 2018 01:08:50 -0500 Received: by localhost.localdomain (Postfix, from userid 0) id ECAFC80D8CA7; Wed, 14 Nov 2018 22:00:15 -0800 (PST) From: root To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, laurent@vivier.eu Date: Wed, 14 Nov 2018 22:00:14 -0800 Message-Id: <1542261614-2606-1-git-send-email-root@localhost.localdomain> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 123.58.160.154 X-Mailman-Approved-At: Thu, 15 Nov 2018 03:01:28 -0500 Subject: [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Li Qiang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Li Qiang And also the g_malloc doesn't need check return value, remove it. Cc: qemu-trivial@nongnu.org Signed-off-by: Li Qiang Reviewed-by: Markus Armbruster --- 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; } =20 - vcpu =3D 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 =3D g_malloc0(sizeof(struct hax_vcpu_state)); =20 ret =3D 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; } =20 - vm =3D g_malloc(sizeof(struct hax_vm)); - if (!vm) { - return NULL; - } - memset(vm, 0, sizeof(struct hax_vm)); + vm =3D g_malloc0(sizeof(struct hax_vm)); + ret =3D hax_host_create_vm(hax, &vm_id); if (ret) { fprintf(stderr, "Failed to create vm %x\n", ret); --=20 2.11.0