From: Lennart Poettering Date: Thu, 20 Apr 2023 16:46:55 +0000 (+0200) Subject: parse-util: allow parse_pid() to work with NULL return parameter X-Git-Tag: v254-rc1~655 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91ce42f008764c3c6d8d72c5fb3b72d0945b7de2;p=thirdparty%2Fsystemd.git parse-util: allow parse_pid() to work with NULL return parameter That way the function becomes useful for validating pids formatted as strings. --- diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c index 3445d313076..a53cbc73b89 100644 --- a/src/basic/parse-util.c +++ b/src/basic/parse-util.c @@ -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; }