Add -Wshadow and deal with the warnings.

This commit is contained in:
Roland C. Dowdeswell
2012-02-21 11:17:55 +00:00
parent cc47c8fa7b
commit e8779d5d4a
39 changed files with 214 additions and 217 deletions

View File

@@ -104,12 +104,12 @@ expand_cell_name(const char *cell)
{
FILE *f;
const char *c;
const char **fn, *files[] = { _PATH_CELLSERVDB,
_PATH_ARLA_CELLSERVDB,
_PATH_OPENAFS_DEBIAN_CELLSERVDB,
_PATH_ARLA_DEBIAN_CELLSERVDB,
NULL };
for(fn = files; *fn; fn++) {
const char **fn, *fns[] = { _PATH_CELLSERVDB,
_PATH_ARLA_CELLSERVDB,
_PATH_OPENAFS_DEBIAN_CELLSERVDB,
_PATH_ARLA_DEBIAN_CELLSERVDB,
NULL };
for(fn = fns; *fn; fn++) {
f = fopen(*fn, "r");
if(f == NULL)
continue;
@@ -212,7 +212,7 @@ log_func(void *ctx, const char *str)
int
main(int argc, char **argv)
{
int optind = 0;
int optidx = 0;
int i;
int num;
int ret = 0;
@@ -221,7 +221,7 @@ main(int argc, char **argv)
setprogname(argv[0]);
if(getarg(args, num_args, argc, argv, &optind))
if(getarg(args, num_args, argc, argv, &optidx))
usage(1);
if(help_flag)
usage(0);
@@ -278,7 +278,7 @@ main(int argc, char **argv)
num++;
}
free_getarg_strings (&cells);
for(i = optind; i < argc; i++){
for(i = optidx; i < argc; i++){
num++;
if(strcmp(argv[i], ".") == 0 ||
strcmp(argv[i], "..") == 0 ||

View File

@@ -104,10 +104,10 @@ main(int argc, char **argv)
char *path;
char **args;
unsigned int i;
int optind = 0;
int optidx = 0;
setprogname(argv[0]);
if(getarg(getargs, num_args, argc, argv, &optind))
if(getarg(getargs, num_args, argc, argv, &optidx))
usage(1);
if(help_flag)
usage(0);
@@ -116,8 +116,8 @@ main(int argc, char **argv)
exit(0);
}
argc -= optind;
argv += optind;
argc -= optidx;
argv += optidx;
#ifdef KRB5
{

View File

@@ -4,6 +4,8 @@ include $(top_srcdir)/Makefile.am.common
AM_CPPFLAGS += -I$(srcdir)/../common -DFTP_SERVER
WFLAGS += $(WFLAGS_LITE)
libexec_PROGRAMS = ftpd
CHECK_LOCAL =

View File

@@ -667,8 +667,6 @@ connect_client(const char *slave)
}
if (logfile) {
int fd;
printf("starting log socket to client %s\n", c->moniker);
fd = wait_log(c);

View File

@@ -58,31 +58,31 @@ static struct getargs args[] = {
static int num_args = sizeof(args) / sizeof(args[0]);
static void
usage(int code, struct getargs *args, int num_args)
usage(int code, struct getargs *inargs, int num_inargs)
{
arg_printusage(args, num_args, NULL, "hosts");
arg_printusage(inargs, num_inargs, NULL, "hosts");
exit(code);
}
static int
client_setup(krb5_context *context, int *argc, char **argv)
client_setup(krb5_context *ctx, int *argc, char **argv)
{
int optind = 0;
int optidx = 0;
int port = 0;
int status;
setprogname (argv[0]);
status = krb5_init_context (context);
status = krb5_init_context (ctx);
if (status)
errx(1, "krb5_init_context failed: %d", status);
forwardable = krb5_config_get_bool (*context, NULL,
forwardable = krb5_config_get_bool (*ctx, NULL,
"libdefaults",
"forwardable",
NULL);
if (getarg (args, num_args, *argc, argv, &optind))
if (getarg (args, num_args, *argc, argv, &optidx))
usage(1, args, num_args);
if(help_flag)
@@ -107,11 +107,11 @@ client_setup(krb5_context *context, int *argc, char **argv)
}
if (port == 0)
port = krb5_getportbyname (*context, KF_PORT_NAME, "tcp", KF_PORT_NUM);
port = krb5_getportbyname (*ctx, KF_PORT_NAME, "tcp", KF_PORT_NUM);
if(*argc - optind < 1)
if(*argc - optidx < 1)
usage(1, args, num_args);
*argc = optind;
*argc = optidx;
return port;
}
@@ -122,7 +122,7 @@ client_setup(krb5_context *context, int *argc, char **argv)
*/
static int
proto (int sock, const char *hostname, const char *service,
proto (int sock, const char *hostname, const char *svc,
char *message, size_t len)
{
krb5_auth_context auth_context;
@@ -153,7 +153,7 @@ proto (int sock, const char *hostname, const char *service,
status = krb5_sname_to_principal (context,
hostname,
service,
svc,
KRB5_NT_SRV_HST,
&server);
if (status) {
@@ -281,7 +281,7 @@ proto (int sock, const char *hostname, const char *service,
}
static int
doit (const char *hostname, int port, const char *service,
doit (const char *hostname, int port, const char *svc,
char *message, size_t len)
{
struct addrinfo *ai, *a;
@@ -312,7 +312,7 @@ doit (const char *hostname, int port, const char *service,
continue;
}
freeaddrinfo (ai);
return proto (s, hostname, service, message, len);
return proto (s, hostname, svc, message, len);
}
warnx ("failed to contact %s", hostname);
freeaddrinfo (ai);

View File

@@ -56,19 +56,19 @@ static struct getargs args[] = {
static int num_args = sizeof(args) / sizeof(args[0]);
static void
usage(int code, struct getargs *args, int num_args)
usage(int code, struct getargs *inargs, int num_inargs)
{
arg_printusage(args, num_args, NULL, "");
arg_printusage(inargs, num_inargs, NULL, "");
exit(code);
}
static int
server_setup(krb5_context *context, int argc, char **argv)
server_setup(krb5_context *ctx, int argc, char **argv)
{
int port = 0;
int local_argc;
local_argc = krb5_program_setup(context, argc, argv, args, num_args, usage);
local_argc = krb5_program_setup(ctx, argc, argv, args, num_args, usage);
if(help_flag)
(*usage)(0, args, num_args);
@@ -92,7 +92,7 @@ server_setup(krb5_context *context, int argc, char **argv)
}
if (port == 0)
port = krb5_getportbyname (*context, KF_PORT_NAME, "tcp", KF_PORT_NUM);
port = krb5_getportbyname (*ctx, KF_PORT_NAME, "tcp", KF_PORT_NUM);
if(argv[local_argc] != NULL)
usage(1, args, num_args);
@@ -120,7 +120,7 @@ kfd_match_version(const void *arg, const char *version)
}
static int
proto (int sock, const char *service)
proto (int sock, const char *svc)
{
krb5_auth_context auth_context;
krb5_error_code status;
@@ -151,7 +151,7 @@ proto (int sock, const char *service)
status = krb5_sname_to_principal (context,
hostname,
service,
svc,
KRB5_NT_SRV_HST,
&server);
if (status)
@@ -281,11 +281,11 @@ proto (int sock, const char *service)
}
static int
doit (int port, const char *service)
doit (int port, const char *svc)
{
if (do_inetd)
mini_inetd(port, NULL);
return proto (STDIN_FILENO, service);
return proto (STDIN_FILENO, svc);
}
int

View File

@@ -73,7 +73,7 @@ usage(int code)
*/
static int
renew (int argc, char **argv, OtpAlgorithm *alg, char *user)
renew (int argc, char **argv, OtpAlgorithm *alg, char *inuser)
{
OtpContext newctx, *ctx;
char prompt[128];
@@ -82,7 +82,7 @@ renew (int argc, char **argv, OtpAlgorithm *alg, char *user)
int ret;
newctx.alg = alg;
newctx.user = user;
newctx.user = inuser;
newctx.n = atoi (argv[0]);
strlcpy (newctx.seed, argv[1], sizeof(newctx.seed));
strlwr(newctx.seed);
@@ -136,7 +136,7 @@ verify_user_otp(char *username)
*/
static int
set (int argc, char **argv, OtpAlgorithm *alg, char *user)
set (int argc, char **argv, OtpAlgorithm *alg, char *inuser)
{
void *db;
OtpContext ctx;
@@ -145,7 +145,7 @@ set (int argc, char **argv, OtpAlgorithm *alg, char *user)
int i;
ctx.alg = alg;
ctx.user = strdup (user);
ctx.user = strdup (inuser);
if (ctx.user == NULL)
err (1, "out of memory");
@@ -178,7 +178,7 @@ set (int argc, char **argv, OtpAlgorithm *alg, char *user)
*/
static int
delete_otp (int argc, char **argv, char *user)
delete_otp (int argc, char **argv, char *inuser)
{
void *db;
OtpContext ctx;
@@ -188,7 +188,7 @@ delete_otp (int argc, char **argv, char *user)
if(db == NULL)
errx (1, "otp_db_open failed");
ctx.user = user;
ctx.user = inuser;
ret = otp_delete(db, &ctx);
otp_db_close (db);
return ret;
@@ -199,7 +199,7 @@ delete_otp (int argc, char **argv, char *user)
*/
static int
has_an_otp(char *user)
has_an_otp(char *inuser)
{
void *db;
OtpContext ctx;
@@ -211,7 +211,7 @@ has_an_otp(char *user)
return 0; /* if no db no otp! */
}
ctx.user = user;
ctx.user = inuser;
ret = otp_simple_get(db, &ctx);
otp_db_close (db);
@@ -223,11 +223,11 @@ has_an_otp(char *user)
*/
static void
print_otp_entry_for_name (void *db, char *user)
print_otp_entry_for_name (void *db, char *inuser)
{
OtpContext ctx;
ctx.user = user;
ctx.user = inuser;
if (!otp_simple_get(db, &ctx)) {
fprintf(stdout,
"%s\totp-%s %d %s",
@@ -242,7 +242,7 @@ print_otp_entry_for_name (void *db, char *user)
}
static int
open_otp (int argc, char **argv, char *user)
open_otp (int argc, char **argv, char *inuser)
{
void *db;
OtpContext ctx;
@@ -252,7 +252,7 @@ open_otp (int argc, char **argv, char *user)
if (db == NULL)
errx (1, "otp_db_open failed");
ctx.user = user;
ctx.user = inuser;
ret = otp_simple_get (db, &ctx);
if (ret == 0)
ret = otp_put (db, &ctx);
@@ -265,7 +265,7 @@ open_otp (int argc, char **argv, char *user)
*/
static int
list_otps (int argc, char **argv, char *user)
list_otps (int argc, char **argv, char *inuser)
{
void *db;
struct passwd *pw;
@@ -274,8 +274,8 @@ list_otps (int argc, char **argv, char *user)
if(db == NULL)
errx (1, "otp_db_open failed");
if (user)
print_otp_entry_for_name(db, user);
if (inuser)
print_otp_entry_for_name(db, inuser);
else
/* scans all users... so as to get a deterministic order */
while ((pw = getpwent()))
@@ -291,10 +291,10 @@ main (int argc, char **argv)
int defaultp = 0;
int uid = getuid();
OtpAlgorithm *alg = otp_find_alg (OTP_ALG_DEFAULT);
int optind = 0;
int optidx = 0;
setprogname (argv[0]);
if(getarg(args, num_args, argc, argv, &optind))
if(getarg(args, num_args, argc, argv, &optidx))
usage(1);
if(help_flag)
usage(0);
@@ -312,8 +312,8 @@ main (int argc, char **argv)
}
if (user && uid != 0)
errx (1, "Only root can use `-u'");
argc -= optind;
argv += optind;
argc -= optidx;
argv += optidx;
if (!(listp || deletep || renewp || openp))
defaultp = 1;

View File

@@ -66,7 +66,7 @@ usage(int code)
static int
print (int argc,
char **argv,
int count,
int incount,
OtpAlgorithm *alg,
void (*print_fn)(OtpKey, char *, size_t))
{
@@ -87,7 +87,7 @@ print (int argc,
char s[64];
alg->next (key);
if (i >= n - count) {
if (i >= n - incount) {
(*print_fn)(key, s, sizeof(s));
printf ("%d: %s\n", i + 1, s);
}
@@ -98,12 +98,12 @@ print (int argc,
int
main (int argc, char **argv)
{
int optind = 0;
int optidx = 0;
void (*fn)(OtpKey, char *, size_t);
OtpAlgorithm *alg = otp_find_alg (OTP_ALG_DEFAULT);
setprogname (argv[0]);
if(getarg(args, num_args, argc, argv, &optind))
if(getarg(args, num_args, argc, argv, &optidx))
usage(1);
if(help_flag)
usage(0);
@@ -117,8 +117,8 @@ main (int argc, char **argv)
if (alg == NULL)
errx(1, "Unknown algorithm: %s", alg_string);
}
argc -= optind;
argv += optind;
argc -= optidx;
argv += optidx;
if (hexp) {
if (extendedp)

View File

@@ -4,6 +4,8 @@ include $(top_srcdir)/Makefile.am.common
AM_CPPFLAGS += $(INCLUDE_hesiod)
WFLAGS += $(WFLAGS_LITE)
bin_SCRIPTS = pfrom
libexec_PROGRAMS = push

View File

@@ -145,7 +145,7 @@ static krb5_ccache ccache;
static int
krb5_verify(const struct passwd *login_info,
const struct passwd *su_info,
const char *kerberos_instance)
const char *instance)
{
krb5_error_code ret;
krb5_principal p;
@@ -176,7 +176,7 @@ krb5_verify(const struct passwd *login_info,
if (strcmp (su_info->pw_name, "root") == 0)
ret = krb5_make_principal(context, &p, *r,
login_name,
kerberos_instance,
instance,
NULL);
else
ret = krb5_make_principal(context, &p, *r,
@@ -327,7 +327,7 @@ verify_unix(struct passwd *login, struct passwd *su)
int
main(int argc, char **argv)
{
int i, optind = 0;
int i, optidx = 0;
char *su_user;
struct passwd *su_info;
struct passwd *login_info;
@@ -340,10 +340,10 @@ main(int argc, char **argv)
setprogname (argv[0]);
if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optind))
if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx))
usage(1);
for (i=0; i < optind; i++)
for (i=0; i < optidx; i++)
if (strcmp(argv[i], "-") == 0) {
full_login = 1;
break;
@@ -355,10 +355,10 @@ main(int argc, char **argv)
print_version(NULL);
exit(0);
}
if(optind >= argc)
if(optidx >= argc)
su_user = "root";
else
su_user = argv[optind++];
su_user = argv[optidx++];
if (!issuid() && getuid() != 0)
warnx("Not setuid and you are not root, expect this to fail");
@@ -446,7 +446,7 @@ main(int argc, char **argv)
if(full_login) {
char *t = getenv ("TERM");
char **newenv = NULL;
int i, j;
int j;
i = read_environment(_PATH_ETC_ENVIRONMENT, &newenv);
@@ -477,8 +477,7 @@ main(int argc, char **argv)
}
{
int i;
char **args;
char **new_argv;
char *p;
p = strrchr(shell, '/');
@@ -490,26 +489,27 @@ main(int argc, char **argv)
if (strcmp(p, "csh") != 0)
csh_f_flag = 0;
args = malloc(((cmd ? 2 : 0) + 1 + argc - optind + 1 + csh_f_flag) * sizeof(*args));
if (args == NULL)
new_argv = malloc(((cmd ? 2 : 0) + 1 + argc - optidx + 1 + csh_f_flag)
* sizeof(*new_argv));
if (new_argv == NULL)
err (1, "malloc");
i = 0;
if(full_login) {
if (asprintf(&args[i++], "-%s", p) == -1)
if (asprintf(&new_argv[i++], "-%s", p) == -1)
errx (1, "malloc");
} else
args[i++] = p;
new_argv[i++] = p;
if (cmd) {
args[i++] = "-c";
args[i++] = cmd;
new_argv[i++] = "-c";
new_argv[i++] = cmd;
}
if (csh_f_flag)
args[i++] = "-f";
new_argv[i++] = "-f";
for (argv += optind; *argv; ++argv)
args[i++] = *argv;
args[i] = NULL;
for (argv += optidx; *argv; ++argv)
new_argv[i++] = *argv;
new_argv[i] = NULL;
if(setgid(su_info->pw_gid) < 0)
err(1, "setgid");
@@ -523,7 +523,7 @@ main(int argc, char **argv)
if (ok == 5)
krb5_start_session();
#endif
execve(shell, args, environ);
execve(shell, new_argv, environ);
}
exit(1);

View File

@@ -263,15 +263,15 @@ init_words (int argc, char **argv)
static void
ScreenSaver(int save)
{
static int timeout, interval, prefer_blank, allow_exp;
static int timeout, ival, prefer_blank, allow_exp;
if(!appres.no_screensaver){
if (save) {
XGetScreenSaver(dpy, &timeout, &interval,
XGetScreenSaver(dpy, &timeout, &ival,
&prefer_blank, &allow_exp);
XSetScreenSaver(dpy, 0, interval, prefer_blank, allow_exp);
XSetScreenSaver(dpy, 0, ival, prefer_blank, allow_exp);
} else
/* restore state */
XSetScreenSaver(dpy, timeout, interval, prefer_blank, allow_exp);
XSetScreenSaver(dpy, timeout, ival, prefer_blank, allow_exp);
}
}
@@ -504,11 +504,11 @@ post_prompt_box(Window window)
static void
RaiseWindow(Widget w, XEvent *ev, String *s, Cardinal *n)
{
Widget x;
Widget new;
if(!XtIsRealized(w))
return;
x = XtParent(w);
XRaiseWindow(dpy, XtWindow(x));
new = XtParent(w);
XRaiseWindow(dpy, XtWindow(new));
}