]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: get_pid(): Move function to "atoi/getnum.h"
authorAlejandro Colomar <alx@kernel.org>
Tue, 9 Jan 2024 15:41:24 +0000 (16:41 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sat, 29 Jun 2024 18:00:18 +0000 (20:00 +0200)
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>
lib/atoi/getnum.c
lib/atoi/getnum.h
lib/commonio.c
lib/get_pid.c
lib/prototypes.h
lib/user_busy.c

index 77dd231233fd19cfaf640946cb821d4bb239f949..29e91581c5ee9af1a0c94f6bb9df27e053534247 100644 (file)
@@ -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);
index c6f93b84b83e2afc1dcfcf1d3f2e30bb0f821e3c..f92173fe84fe3f64f331e104d7f3678ce571a5d7 100644 (file)
@@ -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
index 01a26c96423bd691a9ea66ecc3a160c4590a9f2e..396feff1af550ab63f717156504434ff3b9fbead 100644 (file)
@@ -23,6 +23,7 @@
 #include <signal.h>
 
 #include "alloc.h"
+#include "atoi/getnum.h"
 #include "memzero.h"
 #include "nscd.h"
 #include "sssd.h"
index 4e8f4ef2623e95cd6ce5ece07c98f2ba79187b27..80e1336c3b33b12d5c300e17d3f9e1f11f7357b8 100644 (file)
 #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.
index 40e76625cd8c35a5e7a19bdb7ab43ea9fb94b14d..e36c5dccfec2a2f074eb621d108651e3320e46c9 100644 (file)
@@ -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);
 
index a622376a8abd44682de84bdce51bbbf82c188160..0c7d5cbcad14a71042fd8417c45f87ea04fc8521 100644 (file)
@@ -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