From: Alejandro Colomar Date: Tue, 9 Jan 2024 16:46:21 +0000 (+0100) Subject: lib/, po/, src/: get_uid(): Move function to "atoi/getnum.h" X-Git-Tag: 4.17.0-rc1~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f86f893abff0cb36c3328cba02a172799554825;p=thirdparty%2Fshadow.git lib/, po/, src/: get_uid(): 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" Signed-off-by: Alejandro Colomar --- diff --git a/lib/Makefile.am b/lib/Makefile.am index bcf859833..2a65e1d79 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -74,7 +74,6 @@ libshadow_la_SOURCES = \ find_new_sub_uids.c \ fputsx.c \ get_pid.c \ - get_uid.c \ getdate.h \ getdate.y \ getdef.c \ diff --git a/lib/atoi/getnum.c b/lib/atoi/getnum.c index 1931c0566..3c67eb20b 100644 --- a/lib/atoi/getnum.c +++ b/lib/atoi/getnum.c @@ -13,3 +13,4 @@ extern inline int get_fd(const char *restrict fdstr, int *restrict fd); 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); +extern inline int get_uid(const char *restrict uidstr, uid_t *restrict uid); diff --git a/lib/atoi/getnum.h b/lib/atoi/getnum.h index a459e9099..efb8bcb46 100644 --- a/lib/atoi/getnum.h +++ b/lib/atoi/getnum.h @@ -24,6 +24,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); +ATTR_STRING(1) ATTR_ACCESS(write_only, 2) +inline int get_uid(const char *restrict uidstr, uid_t *restrict uid); inline int @@ -47,4 +49,11 @@ get_pid(const char *restrict pidstr, pid_t *restrict pid) } +inline int +get_uid(const char *restrict uidstr, uid_t *restrict uid) +{ + return a2i(uid_t, uid, uidstr, NULL, 10, type_min(uid_t), type_max(uid_t)); +} + + #endif // include guard diff --git a/lib/get_uid.c b/lib/get_uid.c deleted file mode 100644 index 1224a9a7b..000000000 --- a/lib/get_uid.c +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2009, Nicolas François -// SPDX-FileCopyrightText: 2023, Alejandro Colomar -// SPDX-License-Identifier: BSD-3-Clause - - -#include - -#ident "$Id$" - -#include "atoi/a2i.h" -#include "prototypes.h" - - -int -get_uid(const char *uidstr, uid_t *uid) -{ - return a2i(uid_t, uid, uidstr, NULL, 10, type_min(uid_t), type_max(uid_t)); -} diff --git a/lib/prototypes.h b/lib/prototypes.h index e36c5dccf..6b978a975 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -157,9 +157,6 @@ extern int getrange (const char *range, /* gettime.c */ extern time_t gettime (void); -/* get_uid.c */ -extern int get_uid (const char *uidstr, uid_t *uid); - /* fputsx.c */ ATTR_ACCESS(write_only, 1, 2) extern /*@null@*/char *fgetsx(/*@returned@*/char *restrict, int, FILE *restrict); diff --git a/po/POTFILES.in b/po/POTFILES.in index 9ebbc017b..78eb26407 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -22,7 +22,6 @@ lib/find_new_sub_gids.c lib/find_new_sub_uids.c lib/find_new_uid.c lib/fputsx.c -lib/get_uid.c lib/getdef.c lib/getgr_nam_gid.c lib/getrange.c diff --git a/src/usermod.c b/src/usermod.c index 443f7b578..4e03afbb6 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -34,6 +34,7 @@ #include "alloc.h" #include "atoi/a2i.h" +#include "atoi/getnum.h" #include "atoi/str2i.h" #include "chkname.h" #include "defines.h"