From: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
To: Eric Blake <eblake@redhat.com>,
qemu devel <qemu-devel@nongnu.org>,
qemu block <qemu-block@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Fam Zheng <famz@redhat.com>, Max Reitz <mreitz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>,
Wen Congyang <wency@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] block/replication: prefect the logic to acquire 'top_id'
Date: Wed, 12 Oct 2016 08:40:38 +0800 [thread overview]
Message-ID: <57FD8686.9030802@cn.fujitsu.com> (raw)
In-Reply-To: <5074b60f-3c8e-07e5-a17a-e16a54313979@redhat.com>
On 10/11/2016 10:52 PM, Eric Blake wrote:
> On 10/11/2016 05:46 AM, Changlong Xie wrote:
>> Only g_strdup(top_id) if 'top_id' is not NULL, although there
>> is no memory leak here
>>
>> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
>> ---
>> block/replication.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/block/replication.c b/block/replication.c
>> index 3bd1cf1..5b432d9 100644
>> --- a/block/replication.c
>> +++ b/block/replication.c
>> @@ -104,11 +104,11 @@ static int replication_open(BlockDriverState *bs, QDict *options,
>> } else if (!strcmp(mode, "secondary")) {
>> s->mode = REPLICATION_MODE_SECONDARY;
>> top_id = qemu_opt_get(opts, REPLICATION_TOP_ID);
>> - s->top_id = g_strdup(top_id);
>
> g_strdup(NULL) is safe; it returns NULL in that case.
Yes, that's why i said 'there is no memory leak here' in the commit
message.
>
>> - if (!s->top_id) {
>> + if (!top_id) {
>> error_setg(&local_err, "Missing the option top-id");
>> goto fail;
>> }
>> + s->top_id = g_strdup(top_id);
>
> I see no point to this patch, rather than churn.
It just reduce on execution path. Maybe i'm too academic :)
Will remove it in the next series.
Thanks
-Xie
>
next prev parent reply other threads:[~2016-10-12 0:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 10:46 [Qemu-devel] [PATCH v2 0/2] block/replication fixes Changlong Xie
2016-10-11 10:46 ` [Qemu-devel] [PATCH v2 1/2] block/replication: prefect the logic to acquire 'top_id' Changlong Xie
2016-10-11 14:52 ` Eric Blake
2016-10-12 0:40 ` Changlong Xie [this message]
2016-10-11 10:46 ` [Qemu-devel] [PATCH v2 2/2] block/replication: Clarify 'top-id' parameter usage Changlong Xie
2016-10-11 14:54 ` Eric Blake
2016-10-12 0:41 ` Changlong Xie
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=57FD8686.9030802@cn.fujitsu.com \
--to=xiecl.fnst@cn.fujitsu.com \
--cc=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wency@cn.fujitsu.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.