]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lxcContainerMountFSDevPTS: Unify @ret usage pattern
authorChen Hanxiao <chenhanxiao@cn.fujitsu.com>
Fri, 6 Dec 2013 06:20:21 +0000 (14:20 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 6 Dec 2013 15:27:12 +0000 (16:27 +0100)
Currently, if virFileMakePath() fails, the @ret is left initialized from
virAsprintf() just a few lines above leading to a wrong return value of
zero whereas -1 should be returned.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/lxc/lxc_container.c

index b1b63fb687d7d2c028470669c14e660803bcfd77..b17259c4e177a060c9d3b0d73adcd943993a6dc3 100644 (file)
@@ -940,16 +940,14 @@ cleanup:
 static int lxcContainerMountFSDevPTS(virDomainDefPtr def,
                                      const char *stateDir)
 {
-    int ret;
+    int ret = -1;
     char *path = NULL;
     int flags = def->idmap.nuidmap ? MS_BIND : MS_MOVE;
 
     VIR_DEBUG("Mount /dev/pts stateDir=%s", stateDir);
 
-    if ((ret = virAsprintf(&path,
-                           "/.oldroot/%s/%s.devpts",
-                           stateDir,
-                           def->name)) < 0)
+    if (virAsprintf(&path, "/.oldroot/%s/%s.devpts",
+                    stateDir, def->name) < 0)
         return ret;
 
     if (virFileMakePath("/dev/pts") < 0) {
@@ -961,16 +959,16 @@ static int lxcContainerMountFSDevPTS(virDomainDefPtr def,
     VIR_DEBUG("Trying to %s %s to /dev/pts", def->idmap.nuidmap ?
               "bind" : "move", path);
 
-    if ((ret = mount(path, "/dev/pts", NULL, flags, NULL)) < 0) {
+    if (mount(path, "/dev/pts", NULL, flags, NULL) < 0) {
         virReportSystemError(errno,
                              _("Failed to mount %s on /dev/pts"),
                              path);
         goto cleanup;
     }
 
+    ret = 0;
 cleanup:
     VIR_FREE(path);
-
     return ret;
 }