mirror of
https://github.com/systemd/systemd
synced 2024-07-22 02:34:54 +00:00
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:
parent
13d9669980
commit
91ce42f008
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue