[libvirt] [PATCH v4 2/2] daemon: Remove unnecessary goto error

Wang King king.wang at huawei.com
Mon Apr 24 04:05:25 UTC 2017


Free the dst is unnecessary if the VIR_STRDUP fails, and therefore we need to
remove the error label.
---
 daemon/remote.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index a8c21fd..2709c3c 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -648,7 +648,7 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn,
     /* build return data */
     memset(&data, 0, sizeof(data));
     if (VIR_STRDUP(data.path, path) < 0)
-        goto error;
+        return -1;
     data.type = type;
     data.status = status;
     make_nonnull_domain(&data.dom, dom);
@@ -667,9 +667,6 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn,
     }
 
     return 0;
- error:
-    VIR_FREE(data.path);
-    return -1;
 }
 
 
@@ -1025,7 +1022,7 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
     memset(&data, 0, sizeof(data));
     data.callbackID = callback->callbackID;
     if (VIR_STRDUP(data.dst, dst) < 0)
-        goto error;
+        return -1;
     data.type = type;
     data.status = status;
     make_nonnull_domain(&data.dom, dom);
@@ -1035,9 +1032,6 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
                                   (xdrproc_t)xdr_remote_domain_event_block_job_2_msg, &data);
 
     return 0;
- error:
-    VIR_FREE(data.dst);
-    return -1;
 }
 
 
-- 
2.8.3




More information about the libvir-list mailing list