mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
storage: Invert retval logic in virStorageBackendSCSITriggerRescan
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>
This commit is contained in:
parent
763b76cbf6
commit
5028781621
@ -56,16 +56,14 @@ static int
|
|||||||
virStorageBackendSCSITriggerRescan(uint32_t host)
|
virStorageBackendSCSITriggerRescan(uint32_t host)
|
||||||
{
|
{
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int retval = 0;
|
int retval = -1;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
|
|
||||||
VIR_DEBUG("Triggering rescan of host %d", host);
|
VIR_DEBUG("Triggering rescan of host %d", host);
|
||||||
|
|
||||||
if (virAsprintf(&path, "%s/host%u/scan",
|
if (virAsprintf(&path, "%s/host%u/scan",
|
||||||
LINUX_SYSFS_SCSI_HOST_PREFIX, host) < 0) {
|
LINUX_SYSFS_SCSI_HOST_PREFIX, host) < 0)
|
||||||
retval = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
VIR_DEBUG("Scan trigger path is '%s'", path);
|
VIR_DEBUG("Scan trigger path is '%s'", path);
|
||||||
|
|
||||||
@ -75,7 +73,6 @@ virStorageBackendSCSITriggerRescan(uint32_t host)
|
|||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Could not open '%s' to trigger host scan"),
|
_("Could not open '%s' to trigger host scan"),
|
||||||
path);
|
path);
|
||||||
retval = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,9 +82,11 @@ virStorageBackendSCSITriggerRescan(uint32_t host)
|
|||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Write to '%s' to trigger host scan failed"),
|
_("Write to '%s' to trigger host scan failed"),
|
||||||
path);
|
path);
|
||||||
retval = -1;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retval = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
VIR_FREE(path);
|
VIR_FREE(path);
|
||||||
|
Loading…
Reference in New Issue
Block a user