]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Declare read-only parameters const
authorChristian Göttsche <cgzones@googlemail.com>
Fri, 5 Aug 2022 15:40:26 +0000 (17:40 +0200)
committerSerge Hallyn <serge@hallyn.com>
Sat, 6 Aug 2022 16:27:56 +0000 (11:27 -0500)
Signal callers arguments are not going to be modified and allow passing
const pointers.

lib/prototypes.h
libmisc/find_new_gid.c
libmisc/find_new_uid.c
libmisc/getrange.c
libmisc/idmapping.c
libmisc/idmapping.h

index cd873bf7f94b8652b9d08dab2d6a9008b24d7e13..4e997e32f01e0a9623e5569d9f6fb3fe5acd66e2 100644 (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);
 
index 1bddc12f65475cc96245d70ad1922f53c6cb7de8..666b6107838f1d0ac9c5e1945f7e2e82dac91c57 100644 (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) {
index 41b6c1d1c5a54df2fd4f48d2472a03328249bd5a..322d15ab71ef2c99237649283664037aa3788cea 100644 (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) {
index d620c126ea94e355683afc11b0518df3387c450f..82f2edfa4515426de03213f541134f5ae10530b9 100644 (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)
 {
index 8b64a26a9db23e1bf5879f6cca20d5f06a19fb99..30eb89fde068b7a5f658e53013fed440e4235ee0 100644 (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;
index 81a628b85a3fd847d7a5a20e79196a333142af5a..e20bd60f761e0356d61dede21c870b088e6e9342 100644 (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_ */