From: Alejandro Colomar Date: Tue, 28 Nov 2023 01:05:45 +0000 (+0100) Subject: lib/, src/: Say 'long' instead of 'long int' X-Git-Tag: 4.15.0-rc1~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f16458b6cbcf3ecbdc983084e9d49ca85af27f6;p=thirdparty%2Fshadow.git lib/, src/: Say 'long' instead of 'long int' We were using 'long' in most places, so be consistent and use it everywhere. Signed-off-by: Alejandro Colomar --- diff --git a/lib/defines.h b/lib/defines.h index 969b1aa93..4106a2086 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -190,7 +190,7 @@ #define SHADOW_PASSWD_STRING "x" #endif -#define SHADOW_SP_FLAG_UNSET ((unsigned long int)-1) +#define SHADOW_SP_FLAG_UNSET ((unsigned long)-1) #ifdef WITH_AUDIT #ifdef __u8 /* in case we use pam < 0.80 */ diff --git a/lib/get_gid.c b/lib/get_gid.c index 26ce0319f..a43a7d68b 100644 --- a/lib/get_gid.c +++ b/lib/get_gid.c @@ -13,7 +13,7 @@ int get_gid (const char *gidstr, gid_t *gid) { - long long int val; + long long val; char *endptr; errno = 0; diff --git a/lib/get_pid.c b/lib/get_pid.c index 20f4ce429..5eda20279 100644 --- a/lib/get_pid.c +++ b/lib/get_pid.c @@ -16,7 +16,7 @@ int get_pid (const char *pidstr, pid_t *pid) { - long long int val; + long long val; char *endptr; errno = 0; @@ -40,7 +40,7 @@ int get_pid (const char *pidstr, pid_t *pid) */ int get_pidfd_from_fd(const char *pidfdstr) { - long long int val; + long long val; char *endptr; struct stat st; dev_t proc_st_dev, proc_st_rdev; diff --git a/lib/get_uid.c b/lib/get_uid.c index 4f9f311f0..797b4bb91 100644 --- a/lib/get_uid.c +++ b/lib/get_uid.c @@ -13,7 +13,7 @@ int get_uid (const char *uidstr, uid_t *uid) { - long long int val; + long long val; char *endptr; errno = 0; diff --git a/lib/getgr_nam_gid.c b/lib/getgr_nam_gid.c index f3c2d4586..53a9ee56c 100644 --- a/lib/getgr_nam_gid.c +++ b/lib/getgr_nam_gid.c @@ -23,7 +23,7 @@ */ extern /*@only@*//*@null@*/struct group *getgr_nam_gid (/*@null@*/const char *grname) { - long long int gid; + long long gid; char *endptr; if (NULL == grname) { diff --git a/lib/getlong.c b/lib/getlong.c index ec4aa54d0..6317bf0fa 100644 --- a/lib/getlong.c +++ b/lib/getlong.c @@ -19,7 +19,7 @@ * * Returns 0 on failure, 1 on success. */ -int getlong (const char *numstr, /*@out@*/long int *result) +int getlong (const char *numstr, /*@out@*/long *result) { long val; char *endptr; diff --git a/lib/getulong.c b/lib/getulong.c index 33250e3a9..543fcd47a 100644 --- a/lib/getulong.c +++ b/lib/getulong.c @@ -19,9 +19,9 @@ * * Returns 0 on failure, 1 on success. */ -int getulong (const char *numstr, /*@out@*/unsigned long int *result) +int getulong (const char *numstr, /*@out@*/unsigned long *result) { - unsigned long int val; + unsigned long val; char *endptr; errno = 0; diff --git a/lib/limits.c b/lib/limits.c index 1916f3452..efb24a546 100644 --- a/lib/limits.c +++ b/lib/limits.c @@ -105,7 +105,7 @@ static int set_prio (const char *value) static int set_umask (const char *value) { - unsigned long int mask; + unsigned long mask; if ( (getulong (value, &mask) == 0) || (mask != (mode_t) mask)) { @@ -483,7 +483,8 @@ void setup_limits (const struct passwd *info) } if (strncmp (cp, "pri=", 4) == 0) { - long int inc; + long inc; + if ( (getlong (cp + 4, &inc) == 1) && (inc >= -20) && (inc <= 20)) { errno = 0; @@ -501,7 +502,8 @@ void setup_limits (const struct passwd *info) continue; } if (strncmp (cp, "ulimit=", 7) == 0) { - long int blocks; + long blocks; + if ( (getlong (cp + 7, &blocks) == 0) || (blocks != (int) blocks) || (set_filesize_limit (blocks) != 0)) { @@ -512,7 +514,8 @@ void setup_limits (const struct passwd *info) continue; } if (strncmp (cp, "umask=", 6) == 0) { - unsigned long int mask; + unsigned long mask; + if ( (getulong (cp + 6, &mask) == 0) || (mask != (mode_t) mask)) { SYSLOG ((LOG_WARN, diff --git a/lib/prefix_flag.c b/lib/prefix_flag.c index 9d766818a..d55aeb978 100644 --- a/lib/prefix_flag.c +++ b/lib/prefix_flag.c @@ -337,7 +337,7 @@ extern void prefix_endgrent(void) extern struct group *prefix_getgr_nam_gid(const char *grname) { - long long int gid; + long long gid; char *endptr; struct group *g; diff --git a/lib/prototypes.h b/lib/prototypes.h index 51118fd30..3856d7f8f 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -153,7 +153,7 @@ extern int get_gid (const char *gidstr, gid_t *gid); extern /*@only@*//*@null@*/struct group *getgr_nam_gid (/*@null@*/const char *grname); /* getlong.c */ -extern int getlong (const char *numstr, /*@out@*/long int *result); +extern int getlong (const char *numstr, /*@out@*/long *result); /* get_pid.c */ extern int get_pid (const char *pidstr, pid_t *pid); @@ -172,7 +172,7 @@ extern time_t gettime (void); extern int get_uid (const char *uidstr, uid_t *uid); /* getulong.c */ -extern int getulong (const char *numstr, /*@out@*/unsigned long int *result); +extern int getulong (const char *numstr, /*@out@*/unsigned long *result); /* fputsx.c */ extern /*@null@*/char *fgetsx (/*@returned@*/ /*@out@*/char *, int, FILE *); diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 5c5c00bea..f555b30a4 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -233,7 +233,7 @@ static const struct subordinate_range *find_range(struct commonio_db *db, return NULL; } owner_uid = pwd->pw_uid; - ret = snprintf(owner_uid_string, sizeof (owner_uid_string), "%lu", (unsigned long int)owner_uid); + ret = snprintf(owner_uid_string, sizeof (owner_uid_string), "%lu", (unsigned long)owner_uid); if (ret < 0 || (size_t)ret >= sizeof (owner_uid_string)) return NULL; diff --git a/src/faillog.c b/src/faillog.c index 874528d88..e4eca198e 100644 --- a/src/faillog.c +++ b/src/faillog.c @@ -96,7 +96,7 @@ static off_t lookup_faillog(struct faillog *fl, uid_t uid) if (__builtin_mul_overflow(uid, sizeof(*fl), &offset)) { fprintf(stderr, _("%s: Failed to get the entry for UID %lu\n"), - Prog, (unsigned long int)uid); + Prog, (unsigned long)uid); return -1; } @@ -112,7 +112,7 @@ static off_t lookup_faillog(struct faillog *fl, uid_t uid) if (fread(fl, sizeof(*fl), 1, fail) != 1) { fprintf(stderr, _("%s: Failed to get the entry for UID %lu\n"), - Prog, (unsigned long int)uid); + Prog, (unsigned long)uid); return -1; } } else { @@ -246,7 +246,7 @@ static bool reset_one (uid_t uid) fprintf (stderr, _("%s: Failed to reset fail count for UID %lu\n"), - Prog, (unsigned long int)uid); + Prog, (unsigned long)uid); return true; } @@ -342,7 +342,7 @@ static bool setmax_one (uid_t uid, short max) fprintf (stderr, _("%s: Failed to set max for UID %lu\n"), - Prog, (unsigned long int)uid); + Prog, (unsigned long)uid); return true; } @@ -440,7 +440,7 @@ static bool set_locktime_one (uid_t uid, long locktime) fprintf (stderr, _("%s: Failed to set locktime for UID %lu\n"), - Prog, (unsigned long int)uid); + Prog, (unsigned long)uid); return true; } @@ -557,9 +557,10 @@ int main (int argc, char **argv) break; case 'm': { - long int lmax; + long lmax; + if ( (getlong (optarg, &lmax) == 0) - || ((long int)(short) lmax != lmax)) { + || ((long)(short) lmax != lmax)) { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); diff --git a/src/groupadd.c b/src/groupadd.c index 0a59509a8..d06c32410 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -511,7 +511,7 @@ static void check_flags (void) } else { fprintf (stderr, _("%s: GID '%lu' already exists\n"), - Prog, (unsigned long int) group_id); + Prog, (unsigned long) group_id); exit (E_GID_IN_USE); } } diff --git a/src/groupmod.c b/src/groupmod.c index 11aca7f0c..3c04cdbd3 100644 --- a/src/groupmod.c +++ b/src/groupmod.c @@ -339,7 +339,7 @@ static void check_new_gid (void) */ fprintf (stderr, _("%s: GID '%lu' already exists\n"), - Prog, (unsigned long int) group_newid); + Prog, (unsigned long) group_newid); exit (E_GID_IN_USE); } diff --git a/src/lastlog.c b/src/lastlog.c index cd80de2e8..f96a520c2 100644 --- a/src/lastlog.c +++ b/src/lastlog.c @@ -120,7 +120,7 @@ static void print_one (/*@null@*/const struct passwd *pw) if (fread (&ll, sizeof (ll), 1, lastlogfile) != 1) { fprintf (stderr, _("%s: Failed to get the entry for UID %lu\n"), - Prog, (unsigned long int)pw->pw_uid); + Prog, (unsigned long)pw->pw_uid); exit (EXIT_FAILURE); } } else { @@ -242,7 +242,7 @@ static void update_one (/*@null@*/const struct passwd *pw) if (fwrite (&ll, sizeof(ll), 1, lastlogfile) != 1) { fprintf (stderr, _("%s: Failed to update the entry for UID %lu\n"), - Prog, (unsigned long int)pw->pw_uid); + Prog, (unsigned long)pw->pw_uid); exit (EXIT_FAILURE); } } diff --git a/src/newgidmap.c b/src/newgidmap.c index d6d29725c..39cb66beb 100644 --- a/src/newgidmap.c +++ b/src/newgidmap.c @@ -206,8 +206,8 @@ int main(int argc, char **argv) (getgid() != st.st_gid)) { fprintf(stderr, _( "%s: Target process is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ), Prog, - (unsigned long int)getuid(), (unsigned long int)pw->pw_uid, (unsigned long int)st.st_uid, - (unsigned long int)getgid(), (unsigned long int)pw->pw_gid, (unsigned long int)st.st_gid); + (unsigned long)getuid(), (unsigned long)pw->pw_uid, (unsigned long)st.st_uid, + (unsigned long)getgid(), (unsigned long)pw->pw_gid, (unsigned long)st.st_gid); return EXIT_FAILURE; } diff --git a/src/newuidmap.c b/src/newuidmap.c index e99655c92..5e8c7f3a8 100644 --- a/src/newuidmap.c +++ b/src/newuidmap.c @@ -134,8 +134,8 @@ int main(int argc, char **argv) (getgid() != st.st_gid)) { fprintf(stderr, _( "%s: Target process is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ), Prog, - (unsigned long int)getuid(), (unsigned long int)pw->pw_uid, (unsigned long int)st.st_uid, - (unsigned long int)getgid(), (unsigned long int)pw->pw_gid, (unsigned long int)st.st_gid); + (unsigned long)getuid(), (unsigned long)pw->pw_uid, (unsigned long)st.st_uid, + (unsigned long)getgid(), (unsigned long)pw->pw_gid, (unsigned long)st.st_gid); return EXIT_FAILURE; } diff --git a/src/useradd.c b/src/useradd.c index 9c00d6466..8a5974822 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -875,7 +875,7 @@ static struct group * get_local_group(char * grp_name) { const struct group *grp; struct group *result_grp = NULL; - long long int gid; + long long gid; char *endptr; gid = strtoll (grp_name, &endptr, 10); diff --git a/src/usermod.c b/src/usermod.c index 4f7c7f487..d279981bb 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -319,20 +319,20 @@ static struct ulong_range getulong_range(const char *str) errno = 0; first = strtoll(str, &pos, 10); if (('\0' == *str) || ('-' != *pos ) || (ERANGE == errno) || - (first != (unsigned long int)first)) + (first != (unsigned long)first)) goto out; errno = 0; last = strtoll(pos + 1, &pos, 10); if (('\0' != *pos ) || (ERANGE == errno) || - (last != (unsigned long int)last)) + (last != (unsigned long)last)) goto out; if (first > last) goto out; - result.first = (unsigned long int)first; - result.last = (unsigned long int)last; + result.first = (unsigned long)first; + result.last = (unsigned long)last; out: return result; }