Skip to content

Commit

Permalink
lib/, src/: Say 'long' instead of 'long int'
Browse files Browse the repository at this point in the history
We were using 'long' in most places, so be consistent and use it
everywhere.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
  • Loading branch information
alejandro-colomar authored and hallyn committed Dec 3, 2023
1 parent 44b8f7b commit 4f16458
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lib/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion lib/get_gid.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

int get_gid (const char *gidstr, gid_t *gid)
{
long long int val;
long long val;
char *endptr;

errno = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/get_pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

int get_pid (const char *pidstr, pid_t *pid)
{
long long int val;
long long val;
char *endptr;

errno = 0;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/get_uid.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

int get_uid (const char *uidstr, uid_t *uid)
{
long long int val;
long long val;
char *endptr;

errno = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/getgr_nam_gid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/getlong.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lib/getulong.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions lib/limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand All @@ -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)) {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/prefix_flag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions lib/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 *);
Expand Down
2 changes: 1 addition & 1 deletion lib/subordinateio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
15 changes: 8 additions & 7 deletions src/faillog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/groupadd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/groupmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lastlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/newgidmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/newuidmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/useradd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/usermod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4f16458

Please sign in to comment.