From patchwork Thu Nov 15 06:00:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: root X-Patchwork-Id: 10683647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5804114BA for ; Thu, 15 Nov 2018 08:02:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C302BF95 for ; Thu, 15 Nov 2018 08:02:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D8752C19F; Thu, 15 Nov 2018 08:02:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 651872BF95 for ; Thu, 15 Nov 2018 08:02:26 +0000 (UTC) Received: from localhost ([::1]:37285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNCbZ-00057q-Gq for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 03:02:25 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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; } - 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);