]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virpidfile: Set correct retval in virPidFileReadPath()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 20 Feb 2020 10:36:07 +0000 (11:36 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 20 Feb 2020 11:57:06 +0000 (12:57 +0100)
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 <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virpidfile.c

index a8a743504da55a5bcc369c060ab86b5696f9d32e..d5aa5f4f84391401fca21218b95ba35b0f4b1d30 100644 (file)
@@ -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;
     }