* [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
@ 2018-11-15 6:00 root
2018-11-15 13:32 ` Markus Armbruster
0 siblings, 1 reply; 9+ messages in thread
From: root @ 2018-11-15 6:00 UTC (permalink / raw)
To: pbonzini, rth, ehabkost, laurent; +Cc: qemu-trivial, qemu-devel, Li Qiang
From: Li Qiang <liq3ea@gmail.com>
And also the g_malloc doesn't need check return value,
remove it.
Cc: qemu-trivial@nongnu.org
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..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);
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
@ 2018-11-15 6:05 Li Qiang
2018-11-15 8:34 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Li Qiang @ 2018-11-15 6:05 UTC (permalink / raw)
To: pbonzini, rth, ehabkost, laurent; +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
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..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);
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] target: hax: replace g_malloc with g_malloc0
2018-11-15 6:05 [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0 Li Qiang
@ 2018-11-15 8:34 ` Laurent Vivier
2018-11-15 9:48 ` [Qemu-devel] " Alex Bennée
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Laurent Vivier @ 2018-11-15 8:34 UTC (permalink / raw)
To: Li Qiang, pbonzini, rth, ehabkost; +Cc: qemu-trivial, qemu-devel
On 15/11/2018 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 <liq3ea@gmail.com>
> ---
> target/i386/hax-all.c | 15 +++------------
> 1 file changed, 3 insertions(+), 12 deletions(-)
>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
2018-11-15 6:05 [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0 Li Qiang
2018-11-15 8:34 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
@ 2018-11-15 9:48 ` Alex Bennée
2018-11-15 10:07 ` Philippe Mathieu-Daudé
2018-11-21 17:55 ` Paolo Bonzini
3 siblings, 0 replies; 9+ messages in thread
From: Alex Bennée @ 2018-11-15 9:48 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, rth, ehabkost, laurent, qemu-trivial, Li Qiang
Li Qiang <liq3ea@gmail.com> writes:
> And also the g_malloc doesn't need check return value,
> remove it.
>
> Cc: qemu-trivial@nongnu.org
>
> Signed-off-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> 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);
--
Alex Bennée
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
2018-11-15 6:05 [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0 Li Qiang
2018-11-15 8:34 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
2018-11-15 9:48 ` [Qemu-devel] " Alex Bennée
@ 2018-11-15 10:07 ` Philippe Mathieu-Daudé
2018-11-21 17:55 ` Paolo Bonzini
3 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-15 10:07 UTC (permalink / raw)
To: Li Qiang, pbonzini, rth, ehabkost, laurent; +Cc: qemu-trivial, qemu-devel
On 15/11/18 7: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 <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..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));
Can you use the g_new form?
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_malloc0(sizeof(struct hax_vm));
Ditto.
> +
> 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:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
2018-11-15 6:00 root
@ 2018-11-15 13:32 ` Markus Armbruster
0 siblings, 0 replies; 9+ messages in thread
From: Markus Armbruster @ 2018-11-15 13:32 UTC (permalink / raw)
To: Li Qiang; +Cc: pbonzini, rth, ehabkost, laurent, qemu-trivial, qemu-devel
Your e-mail From: header is messed up. Please fix.
root <root@localhost.localdomain> writes:
> From: Li Qiang <liq3ea@gmail.com>
>
> And also the g_malloc doesn't need check return value,
> remove it.
>
> Cc: qemu-trivial@nongnu.org
>
> 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..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));
Make that g_new0(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));
Likewise.
> +
> ret = hax_host_create_vm(hax, &vm_id);
> if (ret) {
> fprintf(stderr, "Failed to create vm %x\n", ret);
With those two changes:
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
2018-11-15 6:05 [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0 Li Qiang
` (2 preceding siblings ...)
2018-11-15 10:07 ` Philippe Mathieu-Daudé
@ 2018-11-21 17:55 ` Paolo Bonzini
2018-11-22 12:08 ` Laurent Vivier
3 siblings, 1 reply; 9+ messages in thread
From: Paolo Bonzini @ 2018-11-21 17:55 UTC (permalink / raw)
To: Li Qiang, rth, ehabkost, laurent; +Cc: qemu-trivial, qemu-devel
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 <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..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.
Paolo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
2018-11-21 17:55 ` Paolo Bonzini
@ 2018-11-22 12:08 ` Laurent Vivier
2018-11-22 13:04 ` Paolo Bonzini
0 siblings, 1 reply; 9+ messages in thread
From: Laurent Vivier @ 2018-11-22 12:08 UTC (permalink / raw)
To: Paolo Bonzini, Li Qiang, rth, ehabkost
Cc: qemu-trivial, qemu-devel, Markus Armbruster,
Philippe Mathieu-Daudé
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 <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..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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
2018-11-22 12:08 ` Laurent Vivier
@ 2018-11-22 13:04 ` Paolo Bonzini
0 siblings, 0 replies; 9+ messages in thread
From: Paolo Bonzini @ 2018-11-22 13:04 UTC (permalink / raw)
To: Laurent Vivier, Li Qiang, rth, ehabkost
Cc: qemu-trivial, qemu-devel, Markus Armbruster,
Philippe Mathieu-Daudé
On 22/11/18 13:08, Laurent Vivier wrote:
> 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 <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..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().
Sorry, not sure why I didn't notice the replies. Also, it's sent to
qemu-trivial so I'll ignore v2...
Paolo
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-11-22 13:04 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-15 6:05 [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0 Li Qiang
2018-11-15 8:34 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
2018-11-15 9:48 ` [Qemu-devel] " Alex Bennée
2018-11-15 10:07 ` Philippe Mathieu-Daudé
2018-11-21 17:55 ` Paolo Bonzini
2018-11-22 12:08 ` Laurent Vivier
2018-11-22 13:04 ` Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2018-11-15 6:00 root
2018-11-15 13:32 ` Markus Armbruster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).