From: Alejandro Colomar Date: Tue, 9 Jan 2024 15:36:08 +0000 (+0100) Subject: lib/get_pid.c: get_pid(): Reimplement in terms of a2i() X-Git-Tag: 4.17.0-rc1~216 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6fd56468c31a526ddb1822e47c8f81d0183d429a;p=thirdparty%2Fshadow.git lib/get_pid.c: get_pid(): Reimplement in terms of a2i() Reviewed-by: "Serge E. Hallyn" Signed-off-by: Alejandro Colomar --- diff --git a/lib/get_pid.c b/lib/get_pid.c index af3f2f8ea..4e8f4ef26 100644 --- a/lib/get_pid.c +++ b/lib/get_pid.c @@ -14,27 +14,14 @@ #include #include +#include "atoi/a2i.h" #include "string/sprintf.h" int get_pid(const char *pidstr, pid_t *pid) { - char *end; - long long val; - - errno = 0; - val = strtoll(pidstr, &end, 10); - if ( ('\0' == *pidstr) - || ('\0' != *end) - || (0 != errno) - || (val < 1) - || (/*@+longintegral@*/val != (pid_t)val)/*@=longintegral@*/) { - return -1; - } - - *pid = val; - return 0; + return a2i(pid_t, pid, pidstr, NULL, 10, 1, type_max(pid_t)); } /*