mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-24 04:12:20 +00:00
util: pidfile: Sanitize return values of virPidFileReadIfAlive
Return -1 on failure rather than -errno since none of the callers actually cares about the return value. This specifically fixes returns of -ENOMEM in cases of bad usage, which would report wrong error anyways. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
19cfd7e598
commit
b13e45911d
@ -282,7 +282,7 @@ int virPidFileReadPathIfAlive(const char *path,
|
|||||||
* and its executable path resolves to @binpath. This adds
|
* and its executable path resolves to @binpath. This adds
|
||||||
* protection against recycling of previously reaped pids.
|
* protection against recycling of previously reaped pids.
|
||||||
*
|
*
|
||||||
* Returns -errno upon error, or zero on successful
|
* Returns -1 upon error, or zero on successful
|
||||||
* reading of the pidfile. If the PID was not still
|
* reading of the pidfile. If the PID was not still
|
||||||
* alive, zero will be returned, but @pid will be
|
* alive, zero will be returned, but @pid will be
|
||||||
* set to -1.
|
* set to -1.
|
||||||
@ -295,12 +295,15 @@ int virPidFileReadIfAlive(const char *dir,
|
|||||||
g_autofree char *pidfile = NULL;
|
g_autofree char *pidfile = NULL;
|
||||||
|
|
||||||
if (name == NULL || dir == NULL)
|
if (name == NULL || dir == NULL)
|
||||||
return -EINVAL;
|
return -1;
|
||||||
|
|
||||||
if (!(pidfile = virPidFileBuildPath(dir, name)))
|
if (!(pidfile = virPidFileBuildPath(dir, name)))
|
||||||
return -ENOMEM;
|
return -1;
|
||||||
|
|
||||||
return virPidFileReadPathIfAlive(pidfile, pid, binpath);
|
if (virPidFileReadPathIfAlive(pidfile, pid, binpath) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user