提交 e22d844e 编写于 作者: P Peter Krempa

qemu: tpm: Sanitize error values in qemuTPMEmulatorGetPid

The callers don't care about the actual return value, so return -1
rather than errno.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 c3ce8367
...@@ -266,7 +266,7 @@ qemuTPMEmulatorCreatePidFilename(const char *swtpmStateDir, ...@@ -266,7 +266,7 @@ qemuTPMEmulatorCreatePidFilename(const char *swtpmStateDir,
* @shortName: short name of the domain * @shortName: short name of the domain
* @pid: pointer to pid * @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 * If the PID was not still alive, zero will be returned, and @pid will be
* set to -1; * set to -1;
*/ */
...@@ -275,16 +275,16 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, ...@@ -275,16 +275,16 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir,
const char *shortName, const char *shortName,
pid_t *pid) pid_t *pid)
{ {
int ret;
g_autofree char *swtpm = virTPMGetSwtpm(); g_autofree char *swtpm = virTPMGetSwtpm();
g_autofree char *pidfile = qemuTPMEmulatorCreatePidFilename(swtpmStateDir, g_autofree char *pidfile = qemuTPMEmulatorCreatePidFilename(swtpmStateDir,
shortName); shortName);
if (!pidfile) if (!pidfile)
return -ENOMEM; return -1;
ret = virPidFileReadPathIfAlive(pidfile, pid, swtpm); if (virPidFileReadPathIfAlive(pidfile, pid, swtpm) < 0)
return -1;
return ret; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册