Skip to content

Commit

Permalink
lib/, po/, src/: get_uid(): Move function to "atoi/getnum.h"
Browse files Browse the repository at this point in the history
Implement it as an inline function, and add restrict and ATTR_STRING()
and ATTR_ACCESS() as appropriate.

Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Mar 15, 2024
1 parent ae87a7e commit 2769280
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 23 deletions.
1 change: 0 additions & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions lib/atoi/getnum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
9 changes: 9 additions & 0 deletions lib/atoi/getnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
18 changes: 0 additions & 18 deletions lib/get_uid.c

This file was deleted.

3 changes: 0 additions & 3 deletions lib/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/usermod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2769280

Please sign in to comment.