[PATCH 6/8] util: pidfile: Sanitize return values of virPidFileReadIfAlive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/util/virpidfile.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index 3e78735c9c..b1b8e54993 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -282,7 +282,7 @@ int virPidFileReadPathIfAlive(const char *path,
  * and its executable path resolves to @binpath. This adds
  * 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
  * alive, zero will be returned, but @pid will be
  * set to -1.
@@ -295,12 +295,15 @@ int virPidFileReadIfAlive(const char *dir,
     g_autofree char *pidfile = NULL;

     if (name == NULL || dir == NULL)
-        return -EINVAL;
+        return -1;

     if (!(pidfile = virPidFileBuildPath(dir, name)))
-        return -ENOMEM;
+        return -1;
+
+    if (virPidFileReadPathIfAlive(pidfile, pid, binpath) < 0)
+        return -1;

-    return virPidFileReadPathIfAlive(pidfile, pid, binpath);
+    return 0;
 }


-- 
2.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux