lib/get_pid.c: get_pid(): Reimplement in terms of a2i()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-06-29 20:00:18 +02:00
parent 509e3bcbf8
commit 6fd56468c3
+2 -15
View File
@@ -14,27 +14,14 @@
#include <sys/stat.h>
#include <fcntl.h>
#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));
}
/*