diff --git a/lib/atoi/getnum.c b/lib/atoi/getnum.c index 77dd2312..29e91581 100644 --- a/lib/atoi/getnum.c +++ b/lib/atoi/getnum.c @@ -11,3 +11,4 @@ extern inline int get_gid(const char *restrict gidstr, gid_t *restrict gid); +extern inline int get_pid(const char *restrict pidstr, pid_t *restrict pid); diff --git a/lib/atoi/getnum.h b/lib/atoi/getnum.h index c6f93b84..f92173fe 100644 --- a/lib/atoi/getnum.h +++ b/lib/atoi/getnum.h @@ -19,6 +19,8 @@ ATTR_STRING(1) ATTR_ACCESS(write_only, 2) inline int get_gid(const char *restrict gidstr, gid_t *restrict gid); +ATTR_STRING(1) ATTR_ACCESS(write_only, 2) +inline int get_pid(const char *restrict pidstr, pid_t *restrict pid); inline int @@ -28,4 +30,11 @@ get_gid(const char *restrict gidstr, gid_t *restrict gid) } +inline int +get_pid(const char *restrict pidstr, pid_t *restrict pid) +{ + return a2i(pid_t, pid, pidstr, NULL, 10, 1, type_max(pid_t)); +} + + #endif // include guard diff --git a/lib/commonio.c b/lib/commonio.c index 01a26c96..396feff1 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -23,6 +23,7 @@ #include #include "alloc.h" +#include "atoi/getnum.h" #include "memzero.h" #include "nscd.h" #include "sssd.h" diff --git a/lib/get_pid.c b/lib/get_pid.c index 4e8f4ef2..80e1336c 100644 --- a/lib/get_pid.c +++ b/lib/get_pid.c @@ -14,16 +14,10 @@ #include #include -#include "atoi/a2i.h" +#include "atoi/getnum.h" #include "string/sprintf.h" -int -get_pid(const char *pidstr, pid_t *pid) -{ - return a2i(pid_t, pid, pidstr, NULL, 10, 1, type_max(pid_t)); -} - /* * If use passed in fd:4 as an argument, then return the * value '4', the fd to use. diff --git a/lib/prototypes.h b/lib/prototypes.h index 40e76625..e36c5dcc 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -146,7 +146,6 @@ extern int find_new_sub_uids (uid_t *range_start, unsigned long *range_count); extern /*@only@*//*@null@*/struct group *getgr_nam_gid (/*@null@*/const char *grname); /* get_pid.c */ -extern int get_pid (const char *pidstr, pid_t *pid); extern int get_pidfd_from_fd(const char *pidfdstr); extern int open_pidfd(const char *pidstr); diff --git a/lib/user_busy.c b/lib/user_busy.c index a622376a..0c7d5cbc 100644 --- a/lib/user_busy.c +++ b/lib/user_busy.c @@ -17,6 +17,8 @@ #include #include #include + +#include "atoi/getnum.h" #include "defines.h" #include "prototypes.h" #ifdef ENABLE_SUBIDS