Merge pull request #487 from cgzones/misc_warnings

Resolve several compiler warnings
This commit is contained in:
Serge Hallyn 2022-01-03 09:45:12 -06:00 committed by GitHub
commit 39eea79d8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 47 additions and 43 deletions

View File

@ -29,7 +29,7 @@ bool nss_is_initialized() {
return atomic_load(&nss_init_completed);
}
void nss_exit() {
static void nss_exit(void) {
if (nss_is_initialized() && subid_nss) {
dlclose(subid_nss->handle);
free(subid_nss);
@ -38,7 +38,7 @@ void nss_exit() {
}
// nsswitch_path is an argument only to support testing.
void nss_init(char *nsswitch_path) {
void nss_init(const char *nsswitch_path) {
FILE *nssfp = NULL;
char *line = NULL, *p, *token, *saveptr;
size_t len = 0;

View File

@ -164,7 +164,7 @@ extern int getrange (char *range,
unsigned long *max, bool *has_max);
/* gettime.c */
extern time_t gettime ();
extern time_t gettime (void);
/* get_uid.c */
extern int get_uid (const char *uidstr, uid_t *uid);
@ -242,8 +242,8 @@ extern /*@null@*//*@only@*/struct passwd *get_my_pwent (void);
/* nss.c */
#include <libsubid/subid.h>
extern void nss_init(char *nsswitch_path);
extern bool nss_is_initialized();
extern void nss_init(const char *nsswitch_path);
extern bool nss_is_initialized(void);
struct subid_nss_ops {
/*
@ -293,7 +293,7 @@ struct subid_nss_ops {
void *handle;
};
extern struct subid_nss_ops *get_subid_nss_handle();
extern struct subid_nss_ops *get_subid_nss_handle(void);
/* pam_pass_non_interactive.c */
@ -324,12 +324,12 @@ extern struct passwd *prefix_getpwuid(uid_t uid);
extern struct passwd *prefix_getpwnam(const char* name);
extern struct spwd *prefix_getspnam(const char* name);
extern struct group *prefix_getgr_nam_gid(const char *grname);
extern void prefix_setpwent();
extern struct passwd* prefix_getpwent();
extern void prefix_endpwent();
extern void prefix_setgrent();
extern struct group* prefix_getgrent();
extern void prefix_endgrent();
extern void prefix_setpwent(void);
extern struct passwd* prefix_getpwent(void);
extern void prefix_endpwent(void);
extern void prefix_setgrent(void);
extern struct group* prefix_getgrent(void);
extern void prefix_endgrent(void);
/* pwd2spwd.c */
#ifndef USE_PAM

View File

@ -8,9 +8,10 @@
#include <sys/wait.h>
#include <unistd.h>
#include <lib/prototypes.h>
#include "run_part.h"
#include "shadowlog_internal.h"
int run_part (char *script_path, char *name, char *action)
int run_part (char *script_path, const char *name, const char *action)
{
int pid;
int wait_status;
@ -39,7 +40,7 @@ int run_part (char *script_path, char *name, char *action)
return (1);
}
int run_parts (char *directory, char *name, char *action)
int run_parts (const char *directory, const char *name, const char *action)
{
struct dirent **namelist;
int scanlist;
@ -47,7 +48,7 @@ int run_parts (char *directory, char *name, char *action)
int execute_result;
scanlist = scandir (directory, &namelist, 0, alphasort);
if (scanlist<0) {
if (scanlist<=0) {
return (0);
}

View File

@ -1,2 +1,2 @@
int run_part (char *script_path, char *name, char *action);
int run_parts (char *directory, char *name, char *action);
int run_part (char *script_path, const char *name, const char *action);
int run_parts (const char *directory, const char *name, const char *action);

View File

@ -17,7 +17,5 @@ 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);
extern void nss_init(char *nsswitch_path);
#endif /* _ID_MAPPING_H_ */

View File

@ -248,7 +248,7 @@ extern struct spwd *prefix_getspnam(const char* name)
}
}
extern void prefix_setpwent()
extern void prefix_setpwent(void)
{
if (!passwd_db_file) {
setpwent();
@ -261,7 +261,7 @@ extern void prefix_setpwent()
if (!fp_pwent)
return;
}
extern struct passwd* prefix_getpwent()
extern struct passwd* prefix_getpwent(void)
{
if (!passwd_db_file) {
return getpwent();
@ -271,7 +271,7 @@ extern struct passwd* prefix_getpwent()
}
return fgetpwent(fp_pwent);
}
extern void prefix_endpwent()
extern void prefix_endpwent(void)
{
if (!passwd_db_file) {
endpwent();
@ -282,7 +282,7 @@ extern void prefix_endpwent()
fp_pwent = NULL;
}
extern void prefix_setgrent()
extern void prefix_setgrent(void)
{
if (!group_db_file) {
setgrent();
@ -295,14 +295,14 @@ extern void prefix_setgrent()
if (!fp_grent)
return;
}
extern struct group* prefix_getgrent()
extern struct group* prefix_getgrent(void)
{
if (!group_db_file) {
return getgrent();
}
return fgetgrent(fp_grent);
}
extern void prefix_endgrent()
extern void prefix_endgrent(void)
{
if (!group_db_file) {
endgrent();

View File

@ -45,7 +45,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
* don't want to tell us what it is themselves.
*/
if (arg == (char *) 0) {
(void) snprintf (arg0, sizeof arg0, "-%s", Basename ((char *) file));
(void) snprintf (arg0, sizeof arg0, "-%s", Basename (file));
arg0[sizeof arg0 - 1] = '\0';
arg = arg0;
}

View File

@ -11,7 +11,7 @@
const char *Prog;
void usage(void)
static void usage(void)
{
fprintf(stderr, "Usage: %s [-g] user start count\n", Prog);
fprintf(stderr, " Release a user's subuid (or with -g, subgid) range\n");

View File

@ -8,7 +8,7 @@
const char *Prog;
void usage(void)
static void usage(void)
{
fprintf(stderr, "Usage: [-g] %s subuid\n", Prog);
fprintf(stderr, " list uids who own the given subuid\n");

View File

@ -9,7 +9,7 @@
const char *Prog;
void usage(void)
static void usage(void)
{
fprintf(stderr, "Usage: %s [-g] user\n", Prog);
fprintf(stderr, " list subuid ranges for user\n");

View File

@ -455,7 +455,7 @@ static void check_grp_file (int *errors, bool *changed)
struct commonio_entry *gre, *tgre;
struct group *grp;
#ifdef SHADOWGRP
struct sgrp *sgr;
const struct sgrp *sgr;
#endif
/*
@ -596,7 +596,7 @@ static void check_grp_file (int *errors, bool *changed)
*/
if (is_shadow) {
sgr = (struct sgrp *) sgr_locate (grp->gr_name);
sgr = sgr_locate (grp->gr_name);
if (sgr == NULL) {
printf (_("no matching group file entry in %s\n"),
sgr_file);
@ -663,7 +663,7 @@ static void check_grp_file (int *errors, bool *changed)
*/
static void check_sgr_file (int *errors, bool *changed)
{
struct group *grp;
const struct group *grp;
struct commonio_entry *sge, *tsge;
struct sgrp *sgr;
@ -758,7 +758,7 @@ static void check_sgr_file (int *errors, bool *changed)
/*
* Make sure this entry exists in the /etc/group file.
*/
grp = (struct group *) gr_locate (sgr->sg_name);
grp = gr_locate (sgr->sg_name);
if (grp == NULL) {
printf (_("no matching group file entry in %s\n"),
grp_file);

View File

@ -11,7 +11,7 @@
const char *Prog;
void usage(void)
static void usage(void)
{
fprintf(stderr, "Usage: %s [-g] [-n] user count\n", Prog);
fprintf(stderr, " Find a subuid (or with -g, subgid) range for user\n");

View File

@ -73,10 +73,11 @@ static void usage(void)
exit(EXIT_FAILURE);
}
void write_setgroups(int proc_dir_fd, bool allow_setgroups)
static void write_setgroups(int proc_dir_fd, bool allow_setgroups)
{
int setgroups_fd;
char *policy, policy_buffer[4096];
const char *policy;
char policy_buffer[4096];
/*
* Default is "deny", and any "allow" will out-rank a "deny". We don't

View File

@ -379,7 +379,7 @@ int main (int argc, char **argv)
int err = 0;
gid_t gid;
char *cp;
char *progbase;
const char *progbase;
const char *name, *prog;
char *group = NULL;
char *command = NULL;
@ -787,7 +787,7 @@ int main (int argc, char **argv)
* Now I try to find the basename of the login shell. This will
* become argv[0] of the spawned command.
*/
progbase = (char *) Basename ((char *) prog);
progbase = Basename (prog);
/*
* Switch back to her home directory if i am doing login

View File

@ -62,7 +62,7 @@ static void verify_ranges(struct passwd *pw, int ranges,
}
}
void usage(void)
static void usage(void)
{
fprintf(stderr, _("usage: %s <pid> <uid> <loweruid> <count> [ <uid> <loweruid> <count> ] ... \n"), Prog);
exit(EXIT_FAILURE);

View File

@ -464,7 +464,9 @@ static int add_passwd (struct passwd *pwd, const char *password)
{
const struct spwd *sp;
struct spwd spent;
#ifndef USE_PAM
char *cp;
#endif /* !USE_PAM */
#ifndef USE_PAM
void *crypt_arg = NULL;
@ -607,9 +609,11 @@ static int add_passwd (struct passwd *pwd, const char *password)
static void process_flags (int argc, char **argv)
{
int c;
#ifndef USE_PAM
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
int bad_s;
#endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */
#endif /* !USE_PAM */
static struct option long_options[] = {
{"badnames", no_argument, NULL, 'b'},
#ifndef USE_PAM

View File

@ -366,7 +366,7 @@ static void check_pw_file (int *errors, bool *changed)
{
struct commonio_entry *pfe, *tpfe;
struct passwd *pwd;
struct spwd *spw;
const struct spwd *spw;
uid_t min_sys_id = (uid_t) getdef_ulong ("SYS_UID_MIN", 101UL);
uid_t max_sys_id = (uid_t) getdef_ulong ("SYS_UID_MAX", 999UL);
@ -584,7 +584,7 @@ static void check_pw_file (int *errors, bool *changed)
spw_opened = true;
}
#endif /* WITH_TCB */
spw = (struct spwd *) spw_locate (pwd->pw_name);
spw = spw_locate (pwd->pw_name);
if (NULL == spw) {
printf (_("no matching password file entry in %s\n"),
spw_dbname ());

View File

@ -2492,7 +2492,7 @@ int main (int argc, char **argv)
(!user_id || (user_id <= uid_max && user_id >= uid_min));
#endif /* ENABLE_SUBIDS */
if (run_parts ("/etc/shadow-maint/useradd-pre.d", (char*)user_name,
if (run_parts ("/etc/shadow-maint/useradd-pre.d", user_name,
"useradd")) {
exit(1);
}
@ -2715,7 +2715,7 @@ int main (int argc, char **argv)
create_mail ();
}
if (run_parts ("/etc/shadow-maint/useradd-post.d", (char*)user_name,
if (run_parts ("/etc/shadow-maint/useradd-post.d", user_name,
"useradd")) {
exit(1);
}