From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Cc: Laszlo Ersek <lersek@redhat.com>,
qemu-block@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free()
Date: Tue, 7 Mar 2017 18:28:09 +0800 [thread overview]
Message-ID: <20170307102809.GA6623@lemon.lan> (raw)
In-Reply-To: <20170207132723.13934-2-famz@redhat.com>
On Tue, 02/07 21:27, Fam Zheng wrote:
> Laszlo spotted and studied this wasteful "if". He pointed out:
>
> The original virtio_blk_free_request needed an "if" as it accesses one
> field, since 671ec3f05655 ("virtio-blk: Convert VirtIOBlockReq.elem to
> pointer", 2014-06-11); later on in f897bf751fbd ("virtio-blk: embed
> VirtQueueElement in VirtIOBlockReq", 2014-07-09) the field became
> embedded, so the "if" became unnecessary (at which point we were using
> g_slice_free(), but it is the same.
>
> Now drop it.
>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> hw/block/virtio-blk.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 702eda8..2858c31 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -42,9 +42,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
>
> static void virtio_blk_free_request(VirtIOBlockReq *req)
> {
> - if (req) {
> - g_free(req);
> - }
> + g_free(req);
> }
>
> static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
> --
> 2.9.3
>
>
Cc: qemu-trivial@nongnu.org
(Let's drop 2/2 and perhaps merge this via trivial)
Fam
WARNING: multiple messages have this Message-ID (diff)
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Cc: Laszlo Ersek <lersek@redhat.com>,
qemu-block@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free()
Date: Tue, 7 Mar 2017 18:28:09 +0800 [thread overview]
Message-ID: <20170307102809.GA6623@lemon.lan> (raw)
In-Reply-To: <20170207132723.13934-2-famz@redhat.com>
On Tue, 02/07 21:27, Fam Zheng wrote:
> Laszlo spotted and studied this wasteful "if". He pointed out:
>
> The original virtio_blk_free_request needed an "if" as it accesses one
> field, since 671ec3f05655 ("virtio-blk: Convert VirtIOBlockReq.elem to
> pointer", 2014-06-11); later on in f897bf751fbd ("virtio-blk: embed
> VirtQueueElement in VirtIOBlockReq", 2014-07-09) the field became
> embedded, so the "if" became unnecessary (at which point we were using
> g_slice_free(), but it is the same.
>
> Now drop it.
>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> hw/block/virtio-blk.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 702eda8..2858c31 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -42,9 +42,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
>
> static void virtio_blk_free_request(VirtIOBlockReq *req)
> {
> - if (req) {
> - g_free(req);
> - }
> + g_free(req);
> }
>
> static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
> --
> 2.9.3
>
>
Cc: qemu-trivial@nongnu.org
(Let's drop 2/2 and perhaps merge this via trivial)
Fam
next prev parent reply other threads:[~2017-03-07 10:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 13:27 [Qemu-devel] [PATCH 0/2] virtio-blk: clean up around g_free() and inline a few functions Fam Zheng
2017-02-07 13:27 ` [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free() Fam Zheng
2017-02-07 13:48 ` Laszlo Ersek
2017-02-13 14:27 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-03-07 10:28 ` Fam Zheng [this message]
2017-03-07 10:28 ` [Qemu-devel] " Fam Zheng
2017-04-23 17:30 ` [Qemu-trivial] " Michael Tokarev
2017-04-23 17:30 ` [Qemu-devel] " Michael Tokarev
2017-02-07 13:27 ` [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions Fam Zheng
2017-02-07 13:52 ` Laszlo Ersek
2017-02-13 14:28 ` Stefan Hajnoczi
2017-02-14 0:54 ` Fam Zheng
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=20170307102809.GA6623@lemon.lan \
--to=famz@redhat.com \
--cc=lersek@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=stefanha@redhat.com \
/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.