virchrdev: Drop needless 'cleanup' label in virChrdevLockFileCreate()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Michal Privoznik 2020-01-08 09:18:32 +01:00
parent 439eb82e23
commit 0970da7180

View File

@ -105,14 +105,13 @@ static char *virChrdevLockFilePath(const char *dev)
static int virChrdevLockFileCreate(const char *dev) static int virChrdevLockFileCreate(const char *dev)
{ {
g_autofree char *path = NULL; g_autofree char *path = NULL;
int ret = -1;
g_autofree char *pidStr = NULL; g_autofree char *pidStr = NULL;
VIR_AUTOCLOSE lockfd = -1; VIR_AUTOCLOSE lockfd = -1;
pid_t pid; pid_t pid;
/* build lock file path */ /* build lock file path */
if (!(path = virChrdevLockFilePath(dev))) if (!(path = virChrdevLockFilePath(dev)))
goto cleanup; return -1;
/* check if a log file and process holding the lock still exists */ /* check if a log file and process holding the lock still exists */
if (virPidFileReadPathIfAlive(path, &pid, NULL) == 0 && pid >= 0) { if (virPidFileReadPathIfAlive(path, &pid, NULL) == 0 && pid >= 0) {
@ -121,7 +120,7 @@ static int virChrdevLockFileCreate(const char *dev)
_("Requested device '%s' is locked by " _("Requested device '%s' is locked by "
"lock file '%s' held by process %lld"), "lock file '%s' held by process %lld"),
dev, path, (long long) pid); dev, path, (long long) pid);
goto cleanup; return -1;
} else { } else {
/* clean up the stale/corrupted/nonexistent lockfile */ /* clean up the stale/corrupted/nonexistent lockfile */
unlink(path); unlink(path);
@ -142,14 +141,13 @@ static int virChrdevLockFileCreate(const char *dev)
if (errno == EACCES && geteuid() != 0) { if (errno == EACCES && geteuid() != 0) {
VIR_DEBUG("Skipping lock file creation for device '%s in path '%s'.", VIR_DEBUG("Skipping lock file creation for device '%s in path '%s'.",
dev, path); dev, path);
ret = 0; return 0;
goto cleanup;
} }
virReportSystemError(errno, virReportSystemError(errno,
_("Couldn't create lock file for " _("Couldn't create lock file for "
"device '%s' in path '%s'"), "device '%s' in path '%s'"),
dev, path); dev, path);
goto cleanup; return -1;
} }
/* write the pid to the file */ /* write the pid to the file */
@ -159,15 +157,11 @@ static int virChrdevLockFileCreate(const char *dev)
"device '%s' in path '%s'"), "device '%s' in path '%s'"),
dev, path); dev, path);
unlink(path); unlink(path);
goto cleanup; return -1;
} }
/* we hold the lock */ /* we hold the lock */
ret = 0; return 0;
cleanup:
return ret;
} }
/** /**