[libvirt] [PATCH] Fix lxc syntax-check failure

Mark McLoughlin markmc at redhat.com
Thu Apr 16 10:43:54 UTC 2009


>From 7ebf401c747b61b44bdba0aebc85fbead7ec1d12 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Thu, 16 Apr 2009 11:36:41 +0100
Subject: 

Fixes:

 CHECK: avoid_if_before_free
 src/lxc_container.c: if (oldroot) VIR_FREE(oldroot)
 src/lxc_container.c: if (newroot) VIR_FREE(newroot)
 Makefile.maint: found useless "if" before "free" above

and:

 src/lxc_container.c:317:
 Makefile.maint: found trailing blank(s)

Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 src/lxc_container.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/lxc_container.c b/src/lxc_container.c
index ff115d1..67c66bd 100644
--- a/src/lxc_container.c
+++ b/src/lxc_container.c
@@ -282,9 +282,11 @@ static int lxcContainerChildMountSort(const void *a, const void *b)
 
 static int lxcContainerPivotRoot(virDomainFSDefPtr root)
 {
-    int rc;
+    int rc, ret;
     char *oldroot = NULL, *newroot = NULL;
 
+    ret = -1;
+
     /* root->parent must be private, so make / private. */
     if (mount("", "/", NULL, MS_PRIVATE|MS_REC, NULL) < 0) {
         virReportSystemError(NULL, errno, "%s",
@@ -312,7 +314,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
                              oldroot);
         goto err;
     }
-	
+
     /* Create a directory called 'new' in tmpfs */
     if (virAsprintf(&newroot, "%s/new", oldroot) < 0) {
         virReportOOMError(NULL);
@@ -366,15 +368,13 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
         goto err;
     }
 
+    ret = 0;
+
+err:
     VIR_FREE(oldroot);
     VIR_FREE(newroot);
 
-    return 0;
-
-err:
-    if (oldroot) VIR_FREE(oldroot);
-    if (newroot) VIR_FREE(newroot);
-    return -1;
+    return ret;
 }
 
 static int lxcContainerPopulateDevices(void)
-- 
1.6.0.6




More information about the libvir-list mailing list