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