lib/, libsubid/, po/, src/: get_gid(): 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:
+2
-1
@@ -33,6 +33,8 @@ libshadow_la_SOURCES = \
|
||||
alloc.h \
|
||||
atoi/a2i.c \
|
||||
atoi/a2i.h \
|
||||
atoi/getnum.c \
|
||||
atoi/getnum.h \
|
||||
atoi/str2i.c \
|
||||
atoi/str2i.h \
|
||||
atoi/strtoi.c \
|
||||
@@ -71,7 +73,6 @@ libshadow_la_SOURCES = \
|
||||
find_new_sub_gids.c \
|
||||
find_new_sub_uids.c \
|
||||
fputsx.c \
|
||||
get_gid.c \
|
||||
get_pid.c \
|
||||
get_uid.c \
|
||||
getdate.h \
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// SPDX-FileCopyrightText: 2009, Nicolas François
|
||||
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "atoi/getnum.h"
|
||||
|
||||
|
||||
extern inline int get_gid(const char *restrict gidstr, gid_t *restrict gid);
|
||||
@@ -3,19 +3,29 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIB_ATOI_GETNUM_H_
|
||||
#define SHADOW_INCLUDE_LIB_ATOI_GETNUM_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id$"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "atoi/a2i.h"
|
||||
#include "attr.h"
|
||||
#include "typetraits.h"
|
||||
|
||||
|
||||
int
|
||||
get_gid(const char *gidstr, gid_t *gid)
|
||||
ATTR_STRING(1) ATTR_ACCESS(write_only, 2)
|
||||
inline int get_gid(const char *restrict gidstr, gid_t *restrict gid);
|
||||
|
||||
|
||||
inline int
|
||||
get_gid(const char *restrict gidstr, gid_t *restrict gid)
|
||||
{
|
||||
return a2i(gid_t, gid, gidstr, NULL, 10, type_min(gid_t), type_max(gid_t));
|
||||
}
|
||||
|
||||
|
||||
#endif // include guard
|
||||
@@ -142,10 +142,6 @@ extern int find_new_sub_gids (gid_t *range_start, unsigned long *range_count);
|
||||
extern int find_new_sub_uids (uid_t *range_start, unsigned long *range_count);
|
||||
#endif /* ENABLE_SUBIDS */
|
||||
|
||||
|
||||
/* get_gid.c */
|
||||
extern int get_gid (const char *gidstr, gid_t *gid);
|
||||
|
||||
/* getgr_nam_gid.c */
|
||||
extern /*@only@*//*@null@*/struct group *getgr_nam_gid (/*@null@*/const char *grname);
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "atoi/getnum.h"
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
|
||||
#define NFIELDS 4
|
||||
|
||||
/*
|
||||
|
||||
@@ -16,10 +16,12 @@
|
||||
#include <pwd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "atoi/getnum.h"
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
|
||||
#define NFIELDS 7
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user