qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 1/2] block/replication: prefect the logic to


From: Changlong Xie
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

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 <address@hidden>
---
  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









reply via email to

[Prev in Thread] Current Thread [Next in Thread]