target: hax: replace g_malloc with g_malloc0
PATCH 1/1 target: hax: replace g_malloc with g_malloc0
And also the g_malloc doesn't need check return value, remove it.
--- target/i386/hax-all.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
target/i386/hax-all.c +3 -12
@@ -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);
Signature · 1 line
2.11.0
Quoted 10 lines · Li Qiang
And also the
g_mallocdoesn't need check return value, remove it.Signed-off-by Li Qiang <[email protected]>--- target/i386/hax-all.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
Quoted 6 lines · Li Qiang
And also the
g_mallocdoesn't need check return value, remove it.Signed-off-by Li Qiang <[email protected]>
Quoted 27 lines
--- target/i386/hax-all.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)target/i386/hax-all.c +1
-7@@ -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; }
target/i386/hax-all.c struct hax_vm *hax_vm_create(struct hax_state *hax) · line 251
Quoted 10 lines
target/i386/hax-all.c +2
-5- 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);
--
Alex Bennée
Quoted 16 lines · Li Qiang
And also the
g_mallocdoesn't need check return value, remove it.Signed-off-by Li Qiang <[email protected]>--- target/i386/hax-all.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)target/i386/hax-all.c +0
-0@@ -154,13 +154,7 @@ int hax_vcpu_create(int id)return 0 ;
target/i386/hax-all.c int hax_vcpu_create(int id) · line 157
Quoted 10 lines
target/i386/hax-all.c +1
-7} - 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 ));
Can you use the g_new form?
vcpu = g_new0(struct hax_vcpu_state, 1);
target/i386/hax-all.c struct hax_vm *hax_vm_create(struct hax_state *hax) · line 247
Quoted 13 lines
target/i386/hax-all.c +1
-5ret =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 ));
Ditto.
target/i386/hax-all.c struct hax_vm *hax_vm_create(struct hax_state *hax) · line 251
Quoted 5 lines
target/i386/hax-all.c +1
-0+ ret =hax_host_create_vm (hax, &vm_id);if (ret) {fprintf (stderr,"Failed to create vm %x\n" , ret);
This patch as it or using g_new0:
Paolo Bonzini
AppliedQuoted 34 lines · Li Qiang
And also the
g_mallocdoesn't need check return value, remove it.Signed-off-by Li Qiang <[email protected]>--- target/i386/hax-all.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)target/i386/hax-all.c +1
-7@@ -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; }
target/i386/hax-all.c struct hax_vm *hax_vm_create(struct hax_state *hax) · line 251
Quoted 10 lines
target/i386/hax-all.c +2
-5- 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.
Paolo
Quoted 34 lines · Paolo Bonzini
Quoted 33 lines · Li Qiang
And also the
g_mallocdoesn't need check return value, remove it.Signed-off-by Li Qiang <[email protected]>--- target/i386/hax-all.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)target/i386/hax-all.c +1
-7@@ -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; }
Quoted 13 lines
target/i386/hax-all.c struct hax_vm *hax_vm_create(struct hax_state *hax) · line 251
Quoted 11 lines
target/i386/hax-all.c +2
-5- 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
Quoted 49 lines · Laurent Vivier
Quoted 34 lines · Paolo Bonzini
Quoted 33 lines · Li Qiang
And also the
g_mallocdoesn't need check return value, remove it.Signed-off-by Li Qiang <[email protected]>--- target/i386/hax-all.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)target/i386/hax-all.c +1
-7@@ -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; }Quoted 13 lines
target/i386/hax-all.c struct hax_vm *hax_vm_create(struct hax_state *hax) · line 251
Quoted 11 lines
target/i386/hax-all.c +2
-5- 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.
Quoted 1 line
Markus and Philippe have asked to use
g_new0()rather thang_malloc0().
Sorry, not sure why I didn't notice the replies. Also, it's sent to qemu-trivial so I'll ignore v2...
Paolo