[PATCH 5/8] qemu: gpu: Sanitize error values in qemuVhostUserGPUGetPid

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

 



The caller doesn't care about the actual return value, so return -1
rather than errno.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_vhost_user_gpu.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c
index 37e424eac3..51244f9b35 100644
--- a/src/qemu/qemu_vhost_user_gpu.c
+++ b/src/qemu/qemu_vhost_user_gpu.c
@@ -61,7 +61,7 @@ qemuVhostUserGPUCreatePidFilename(const char *stateDir,
  * @alias: video device alias
  * @pid: pointer to pid
  *
- * Return -errno upon error, or zero on successful reading of the pidfile.
+ * Return -1 upon error, or zero on successful reading of the pidfile.
  * If the PID was not still alive, zero will be returned, and @pid will be
  * set to -1;
  */
@@ -74,11 +74,13 @@ qemuVhostUserGPUGetPid(const char *binPath,
 {
     g_autofree char *pidfile = NULL;

-    pidfile = qemuVhostUserGPUCreatePidFilename(stateDir, shortName, alias);
-    if (!pidfile)
-        return -ENOMEM;
+    if (!(pidfile = qemuVhostUserGPUCreatePidFilename(stateDir, shortName, alias)))
+        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