libxl/colo: unified exit path for colo_proxy_checkpoint
authorWei Liu <wei.liu2@citrix.com>
Wed, 15 Mar 2017 10:50:19 +0000 (10:50 +0000)
committerWei Liu <wei.liu2@citrix.com>
Thu, 16 Mar 2017 18:25:16 +0000 (18:25 +0000)
Slightly refactor the code to have only one exit path for the said
function.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
tools/libxl/libxl_colo_proxy.c

index c3d55104ea718f5142a82e2f1422e527307063f2..5475f7ea32ea72dd3be28410c603b1aa91982698 100644 (file)
@@ -375,7 +375,7 @@ typedef struct colo_msg {
 int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,
                           unsigned int timeout_us)
 {
-    uint8_t *buff;
+    uint8_t *buff = NULL;
     int64_t size;
     struct nlmsghdr *h;
     struct colo_msg *m;
@@ -396,7 +396,7 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,
         ret = colo_userspace_proxy_recv(cps, recvbuff, timeout_us);
         if (ret <= 0) {
             ret = 0;
-            goto out1;
+            goto out;
         }
 
         if (!strcmp(recvbuff, "DO_CHECKPOINT")) {
@@ -405,14 +405,16 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,
             LOGD(ERROR, ao->domid, "receive qemu colo-compare checkpoint error");
             ret = 0;
         }
-        goto out1;
+        goto out;
     }
 
     size = colo_proxy_recv(cps, &buff, timeout_us);
 
     /* timeout, return no checkpoint message. */
-    if (size <= 0)
-        return 0;
+    if (size <= 0) {
+        ret = 0;
+        goto out;
+    }
 
     h = (struct nlmsghdr *) buff;
 
@@ -433,7 +435,4 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,
 out:
     free(buff);
     return ret;
-
-out1:
-    return ret;
 }