]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Invert retval logic in virStorageBackendSCSITriggerRescan
authorJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 02:48:53 +0000 (21:48 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 13:51:23 +0000 (08:51 -0500)
Rather than initialize to 0 and change to -1 on error, let's do the
normal operation of initializing to -1 and set to 0 on success.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/storage/storage_backend_scsi.c

index 85a177865fdd1632842253ef4438f716afafd5a9..591bcb04e2bf88f9e1fd62963a7cf29af1142be0 100644 (file)
@@ -56,16 +56,14 @@ static int
 virStorageBackendSCSITriggerRescan(uint32_t host)
 {
     int fd = -1;
-    int retval = 0;
+    int retval = -1;
     char *path = NULL;
 
     VIR_DEBUG("Triggering rescan of host %d", host);
 
     if (virAsprintf(&path, "%s/host%u/scan",
-                    LINUX_SYSFS_SCSI_HOST_PREFIX, host) < 0) {
-        retval = -1;
+                    LINUX_SYSFS_SCSI_HOST_PREFIX, host) < 0)
         goto cleanup;
-    }
 
     VIR_DEBUG("Scan trigger path is '%s'", path);
 
@@ -75,7 +73,6 @@ virStorageBackendSCSITriggerRescan(uint32_t host)
         virReportSystemError(errno,
                              _("Could not open '%s' to trigger host scan"),
                              path);
-        retval = -1;
         goto cleanup;
     }
 
@@ -85,9 +82,11 @@ virStorageBackendSCSITriggerRescan(uint32_t host)
         virReportSystemError(errno,
                              _("Write to '%s' to trigger host scan failed"),
                              path);
-        retval = -1;
+        goto cleanup;
     }
 
+    retval = 0;
+
  cleanup:
     VIR_FORCE_CLOSE(fd);
     VIR_FREE(path);