]> xenbits.xensource.com Git - libvirt.git/commitdiff
lock_daemon: Simplify error handling
authorPeter Krempa <pkrempa@redhat.com>
Wed, 16 Jan 2013 10:51:21 +0000 (11:51 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 17 Jan 2013 15:39:29 +0000 (16:39 +0100)
No need to check the run_dir variable twice for NULL.

src/locking/lock_daemon.c

index f0eba48425ebbbf219d37f3fa6811176792bc95e..97e5d749c2b1c0a9198c2a1d05803a46558c8dcd 100644 (file)
@@ -1311,19 +1311,16 @@ int main(int argc, char **argv) {
 
     /* Ensure the rundir exists (on tmpfs on some systems) */
     if (privileged) {
-        run_dir = strdup(LOCALSTATEDIR "/run/libvirt");
+        if (!(run_dir = strdup(LOCALSTATEDIR "/run/libvirt"))) {
+            virReportOOMError();
+            goto cleanup;
+        }
     } else {
-        run_dir = virGetUserRuntimeDirectory();
-
-        if (!run_dir) {
+        if (!(run_dir = virGetUserRuntimeDirectory())) {
             VIR_ERROR(_("Can't determine user directory"));
             goto cleanup;
         }
     }
-    if (!run_dir) {
-        virReportOOMError();
-        goto cleanup;
-    }
 
     if (privileged)
         old_umask = umask(022);