lib/: get_pid(): Move function to "atoi/getnum.h"
Implement it as an inline function, and add restrict and ATTR_STRING() and ATTR_ACCESS() as appropriate. Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "atoi/getnum.h"
|
||||
#include "memzero.h"
|
||||
#include "nscd.h"
|
||||
#include "sssd.h"
|
||||
|
||||
+1
-7
@@ -14,16 +14,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "atoi/getnum.h"
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#ifdef ENABLE_SUBIDS
|
||||
|
||||
Reference in New Issue
Block a user