From ac21e39faacc0ae4d68c9952c588918745135659 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 20 Feb 2020 11:36:07 +0100 Subject: [PATCH] virpidfile: Set correct retval in virPidFileReadPath() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The virPidFileReadPath() function is supposed to return 0 on success or a negative value on failure. But the negative value has a special meaning - it's negated errno. Therefore, when converting string to int we shouldn't return -1 which translates to EPERM. Returning EINVAL looks closer to the truth. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/util/virpidfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index a8a743504d..d5aa5f4f84 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -130,7 +130,7 @@ int virPidFileReadPath(const char *path, if (virStrToLong_ll(pidstr, &endptr, 10, &pid_value) < 0 || !(*endptr == '\0' || g_ascii_isspace(*endptr)) || (pid_t) pid_value != pid_value) { - rc = -1; + rc = -EINVAL; goto cleanup; } -- GitLab