]> xenbits.xensource.com Git - libvirt.git/commitdiff
LXC cleanup deep indentation in lxcDomainSetAutostart
authorRyota Ozaki <ozaki.ryota@gmail.com>
Thu, 5 Nov 2009 12:41:14 +0000 (13:41 +0100)
committerDaniel Veillard <veillard@redhat.com>
Thu, 5 Nov 2009 12:41:14 +0000 (13:41 +0100)
* src/lxc/lxc_driver.c: refactor lxcDomainSetAutostart() to avoid deep
  indentation of the code

src/lxc/lxc_driver.c

index 9f20d0581a2b08ebe215ff272f70db40c418c4c7..a917a46e539c69585ae5ca1b5b145ddf8e640d4a 100644 (file)
@@ -1992,39 +1992,46 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
 
     autostart = (autostart != 0);
 
-    if (vm->autostart != autostart) {
-        if ((configFile = virDomainConfigFile(dom->conn, driver->configDir, vm->def->name)) == NULL)
-            goto cleanup;
-        if ((autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir, vm->def->name)) == NULL)
-            goto cleanup;
+    if (vm->autostart == autostart) {
+        ret = 0;
+        goto cleanup;
+    }
 
-        if (autostart) {
-            int err;
+    configFile = virDomainConfigFile(dom->conn, driver->configDir,
+                                     vm->def->name);
+    if (configFile == NULL)
+        goto cleanup;
+    autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir,
+                                        vm->def->name);
+    if (autostartLink == NULL)
+        goto cleanup;
 
-            if ((err = virFileMakePath(driver->autostartDir))) {
-                virReportSystemError(dom->conn, err,
-                                     _("Cannot create autostart directory %s"),
-                                     driver->autostartDir);
-                goto cleanup;
-            }
+    if (autostart) {
+        int err;
 
-            if (symlink(configFile, autostartLink) < 0) {
-                virReportSystemError(dom->conn, errno,
-                                     _("Failed to create symlink '%s to '%s'"),
-                                     autostartLink, configFile);
-                goto cleanup;
-            }
-        } else {
-            if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
-                virReportSystemError(dom->conn, errno,
-                                     _("Failed to delete symlink '%s'"),
-                                     autostartLink);
-                goto cleanup;
-            }
+        if ((err = virFileMakePath(driver->autostartDir))) {
+            virReportSystemError(dom->conn, err,
+                                 _("Cannot create autostart directory %s"),
+                                 driver->autostartDir);
+            goto cleanup;
         }
 
-        vm->autostart = autostart;
+        if (symlink(configFile, autostartLink) < 0) {
+            virReportSystemError(dom->conn, errno,
+                                 _("Failed to create symlink '%s to '%s'"),
+                                 autostartLink, configFile);
+            goto cleanup;
+        }
+    } else {
+        if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
+            virReportSystemError(dom->conn, errno,
+                                 _("Failed to delete symlink '%s'"),
+                                 autostartLink);
+            goto cleanup;
+        }
     }
+
+    vm->autostart = autostart;
     ret = 0;
 
 cleanup: