All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH] target: hax: replace g_malloc with g_new0
@ 2018-11-26  9:56 ` Li Qiang
  0 siblings, 0 replies; 8+ messages in thread
From: Li Qiang @ 2018-11-26  9:56 UTC (permalink / raw)
  To: pbonzini, rth, ehabkost, laurent, alex.bennee, philmd, armbru
  Cc: qemu-trivial, qemu-devel, Li Qiang

And also the g_malloc doesn't need check return value,
remove it.

Cc: qemu-trivial@nongnu.org

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 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..502ce6f0af 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_new0(struct hax_vcpu_state, 1);
 
     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_new0(struct hax_vm, 1);
+
     ret = hax_host_create_vm(hax, &vm_id);
     if (ret) {
         fprintf(stderr, "Failed to create vm %x\n", ret);
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-11-27 11:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-26  9:56 [Qemu-trivial] [PATCH] target: hax: replace g_malloc with g_new0 Li Qiang
2018-11-26  9:56 ` [Qemu-devel] " Li Qiang
2018-11-26  9:59 ` [Qemu-trivial] " Laurent Vivier
2018-11-26  9:59   ` [Qemu-devel] " Laurent Vivier
2018-11-26 11:27 ` [Qemu-trivial] " Alex Bennée
2018-11-26 11:27   ` [Qemu-devel] " Alex Bennée
2018-11-27 11:30 ` [Qemu-trivial] " Laurent Vivier
2018-11-27 11:30   ` [Qemu-devel] " Laurent Vivier

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.