[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH] target: hax: replace g_malloc with g_malloc0
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-trivial] [PATCH] target: hax: replace g_malloc with g_malloc0 |
Date: |
Thu, 22 Nov 2018 14:04:03 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 |
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: address@hidden
>>>
>>> Signed-off-by: Li Qiang <address@hidden>
>>> ---
>>> 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