]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
src: Fix label logic in virStorageBackendSCSITriggerRescan
authorJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 02:46:28 +0000 (21:46 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 13:51:23 +0000 (08:51 -0500)
Let's initialize @path to NULL, then rather than use two labels
free_path and out labels, let's use the cleanup: label to call
VIR_FREE(path); and VIR_FORCE_CLOSE(fd);

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

index 14f01f9ec081ff216d4bfa2eb04b03d55e6289f8..85a177865fdd1632842253ef4438f716afafd5a9 100644 (file)
@@ -57,14 +57,14 @@ virStorageBackendSCSITriggerRescan(uint32_t host)
 {
     int fd = -1;
     int retval = 0;
-    char *path;
+    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;
-        goto out;
+        goto cleanup;
     }
 
     VIR_DEBUG("Scan trigger path is '%s'", path);
@@ -76,23 +76,21 @@ virStorageBackendSCSITriggerRescan(uint32_t host)
                              _("Could not open '%s' to trigger host scan"),
                              path);
         retval = -1;
-        goto free_path;
+        goto cleanup;
     }
 
     if (safewrite(fd,
                   LINUX_SYSFS_SCSI_HOST_SCAN_STRING,
                   sizeof(LINUX_SYSFS_SCSI_HOST_SCAN_STRING)) < 0) {
-        VIR_FORCE_CLOSE(fd);
         virReportSystemError(errno,
                              _("Write to '%s' to trigger host scan failed"),
                              path);
         retval = -1;
     }
 
+ cleanup:
     VIR_FORCE_CLOSE(fd);
- free_path:
     VIR_FREE(path);
- out:
     VIR_DEBUG("Rescan of host %d complete", host);
     return retval;
 }