From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com,
laurent@vivier.eu, qemu-trivial@nongnu.org,
Li Qiang <liq3ea@gmail.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
Date: Thu, 15 Nov 2018 09:48:02 +0000 [thread overview]
Message-ID: <87muqad63x.fsf@linaro.org> (raw)
In-Reply-To: <1542261954-4060-1-git-send-email-liq3ea@gmail.com>
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
WARNING: multiple messages have this Message-ID (diff)
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com,
laurent@vivier.eu, qemu-trivial@nongnu.org,
Li Qiang <liq3ea@gmail.com>
Subject: Re: [Qemu-devel] [PATCH] target: hax: replace g_malloc with g_malloc0
Date: Thu, 15 Nov 2018 09:48:02 +0000 [thread overview]
Message-ID: <87muqad63x.fsf@linaro.org> (raw)
In-Reply-To: <1542261954-4060-1-git-send-email-liq3ea@gmail.com>
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
next prev parent reply other threads:[~2018-11-15 9:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 6:05 [Qemu-trivial] [PATCH] target: hax: replace g_malloc with g_malloc0 Li Qiang
2018-11-15 6:05 ` [Qemu-devel] " Li Qiang
2018-11-15 8:34 ` [Qemu-trivial] " Laurent Vivier
2018-11-15 8:34 ` [Qemu-devel] " Laurent Vivier
2018-11-15 9:48 ` Alex Bennée [this message]
2018-11-15 9:48 ` [Qemu-devel] " Alex Bennée
2018-11-15 10:07 ` [Qemu-trivial] " Philippe Mathieu-Daudé
2018-11-15 10:07 ` Philippe Mathieu-Daudé
2018-11-21 17:55 ` [Qemu-trivial] " Paolo Bonzini
2018-11-21 17:55 ` [Qemu-devel] " Paolo Bonzini
2018-11-22 12:08 ` [Qemu-trivial] " Laurent Vivier
2018-11-22 12:08 ` [Qemu-devel] " Laurent Vivier
2018-11-22 13:04 ` [Qemu-trivial] " Paolo Bonzini
2018-11-22 13:04 ` [Qemu-devel] " Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2018-11-15 6:00 [Qemu-trivial] " root
2018-11-15 13:32 ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87muqad63x.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=ehabkost@redhat.com \
--cc=laurent@vivier.eu \
--cc=liq3ea@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.