From: Alan Jenkins Date: Tue, 3 Oct 2017 11:13:06 +0000 (+0100) Subject: systemctl: use pid_is_valid() where appropriate X-Git-Tag: v235~22^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72b3f82e1771e1070853a084a6108082c59ab0cb;p=platform%2Fupstream%2Fsystemd.git systemctl: use pid_is_valid() where appropriate This was the one valid site in commit ee043777be58251e7441b4f04594e9e3792d7fb2. The second part of this hunk, avoiding using `%m` when we didn't actually have `errno` set, seems like a nice enough cleanup to be worthwhile on it's own. Also use PID_FMT to improve the error message we print (pid_t is signed). --- diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index c569663..ca03fb4 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -3375,8 +3375,10 @@ static int logind_check_inhibitors(enum action a) { if (!sv) return log_oom(); - if ((pid_t) pid < 0) - return log_error_errno(ERANGE, "Bad PID %"PRIu32": %m", pid); + if (!pid_is_valid((pid_t) pid)) { + log_error("Invalid PID "PID_FMT".", (pid_t) pid); + return -ERANGE; + } if (!strv_contains(sv, IN_SET(a,