Declare read-only parameters const

Signal callers arguments are not going to be modified and allow passing
const pointers.
This commit is contained in:
Christian Göttsche 2022-08-05 17:40:26 +02:00 committed by Serge Hallyn
parent 0fe4128ee6
commit e32b4a9a81
6 changed files with 9 additions and 9 deletions

View File

@ -159,7 +159,7 @@ extern int getlong (const char *numstr, /*@out@*/long int *result);
extern int get_pid (const char *pidstr, pid_t *pid);
/* getrange */
extern int getrange (char *range,
extern int getrange (const char *range,
unsigned long *min, bool *has_min,
unsigned long *max, bool *has_max);

View File

@ -98,7 +98,7 @@ static int get_ranges (bool sys_group, gid_t *min_id, gid_t *max_id,
static int check_gid (const gid_t gid,
const gid_t gid_min,
const gid_t gid_max,
bool *used_gids)
const bool *used_gids)
{
/* First test that the preferred ID is in the range */
if (gid < gid_min || gid > gid_max) {

View File

@ -98,7 +98,7 @@ static int get_ranges (bool sys_user, uid_t *min_id, uid_t *max_id,
static int check_uid(const uid_t uid,
const uid_t uid_min,
const uid_t uid_max,
bool *used_uids)
const bool *used_uids)
{
/* First test that the preferred ID is in the range */
if (uid < uid_min || uid > uid_max) {

View File

@ -25,7 +25,7 @@
* If the range is valid, getrange returns 1.
* If the range is not valid, getrange returns 0.
*/
int getrange (char *range,
int getrange (const char *range,
unsigned long *min, bool *has_min,
unsigned long *max, bool *has_max)
{

View File

@ -102,10 +102,10 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
#define ULONG_DIGITS ((((sizeof(unsigned long) * CHAR_BIT) + 9)/10)*3)
#if HAVE_SYS_CAPABILITY_H
static inline bool maps_lower_root(int cap, int ranges, struct map_range *mappings)
static inline bool maps_lower_root(int cap, int ranges, const struct map_range *mappings)
{
int idx;
struct map_range *mapping;
const struct map_range *mapping;
if (cap != CAP_SETUID)
return false;
@ -135,11 +135,11 @@ static inline bool maps_lower_root(int cap, int ranges, struct map_range *mappin
* when the root user calls the new{g,u}idmap binary for an unprivileged user.
* If this is wanted: use file capabilities!
*/
void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings,
void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings,
const char *map_file, uid_t ruid)
{
int idx;
struct map_range *mapping;
const struct map_range *mapping;
size_t bufsize;
char *buf, *pos;
int fd;

View File

@ -15,7 +15,7 @@ struct map_range {
extern struct map_range *get_map_ranges(int ranges, int argc, char **argv);
extern void write_mapping(int proc_dir_fd, int ranges,
struct map_range *mappings, const char *map_file, uid_t ruid);
const struct map_range *mappings, const char *map_file, uid_t ruid);
#endif /* _ID_MAPPING_H_ */