parse-util: allow parse_pid() to work with NULL return parameter

That way the function becomes useful for validating pids formatted as
strings.
This commit is contained in:
Lennart Poettering 2023-04-20 18:46:55 +02:00 committed by Mike Yuan
parent 13d9669980
commit 91ce42f008

View file

@ -50,7 +50,6 @@ int parse_pid(const char *s, pid_t* ret_pid) {
int r;
assert(s);
assert(ret_pid);
r = safe_atolu(s, &ul);
if (r < 0)
@ -64,7 +63,8 @@ int parse_pid(const char *s, pid_t* ret_pid) {
if (!pid_is_valid(pid))
return -ERANGE;
*ret_pid = pid;
if (ret_pid)
*ret_pid = pid;
return 0;
}