Turn on -Wextra -Wno-sign-compare -Wno-unused-paramter and fix issues.

We turn on a few extra warnings and fix the fallout that occurs
when building with --enable-developer.  Note that we get different
warnings on different machines and so this will be a work in
progress.  So far, we have built on NetBSD/amd64 5.99.64 (which
uses gcc 4.5.3) and Ubuntu 10.04.3 LTS (which uses gcc 4.4.3).

Notably, we fixed

	1.  a lot of missing structure initialisers,

	2.  unchecked return values for functions that glibc
	    marks as __attribute__((warn-unused-result)),

	3.  made minor modifications to slc and asn1_compile
	    which can generate code which generates warnings,
	    and

	4.  a few stragglers here and there.

We turned off the extended warnings for many programs in appl/ as
they are nearing the end of their useful lifetime, e.g.  rsh, rcp,
popper, ftp and telnet.

Interestingly, glibc's strncmp() macro needed to be worked around
whereas the function calls did not.

We have not yet tried this on 32 bit platforms, so there will be
a few more warnings when we do.
This commit is contained in:
Roland C. Dowdeswell
2012-02-20 19:45:41 +00:00
parent 8ce8cb509a
commit cc47c8fa7b
147 changed files with 1083 additions and 665 deletions

View File

@@ -139,8 +139,8 @@ static int version_flag = 0;
static int help_flag = 0;
static struct getargs args[] = {
{ "version", 0, arg_flag, &version_flag },
{ "help", 0, arg_flag, &help_flag }
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
{ "help", 0, arg_flag, &help_flag, NULL, NULL }
};
static void

View File

@@ -125,10 +125,18 @@ add_one_principal (const char *name,
} else if(password == NULL) {
char *princ_name;
char *prompt;
int aret;
krb5_unparse_name(context, princ_ent, &princ_name);
asprintf (&prompt, "%s's Password: ", princ_name);
ret = krb5_unparse_name(context, princ_ent, &princ_name);
if (ret)
goto out;
aret = asprintf (&prompt, "%s's Password: ", princ_name);
free (princ_name);
if (aret == -1) {
ret = ENOMEM;
krb5_set_error_message(context, ret, "out of memory");
goto out;
}
ret = UI_UTIL_read_pw_string (pwbuf, sizeof(pwbuf), prompt, 1);
free (prompt);
if (ret) {

View File

@@ -85,14 +85,19 @@ set_password (krb5_principal principal, char *password, int keepold)
{
krb5_error_code ret = 0;
char pwbuf[128];
int aret;
if(password == NULL) {
char *princ_name;
char *prompt;
krb5_unparse_name(context, principal, &princ_name);
asprintf(&prompt, "%s's Password: ", princ_name);
ret = krb5_unparse_name(context, principal, &princ_name);
if (ret)
return ret;
aret = asprintf(&prompt, "%s's Password: ", princ_name);
free (princ_name);
if (aret == -1)
return ENOMEM;
ret = UI_UTIL_read_pw_string(pwbuf, sizeof(pwbuf), prompt, 1);
free (prompt);
if(ret){

View File

@@ -66,7 +66,7 @@ static struct field_name {
{ "aliases", KADM5_TL_DATA, KRB5_TL_ALIASES, 0, "Aliases", "Aliases", 0 },
{ "hist-kvno-diff-clnt", KADM5_TL_DATA, KRB5_TL_HIST_KVNO_DIFF_CLNT, 0, "Clnt hist keys", "Historic keys allowed for client", 0 },
{ "hist-kvno-diff-svc", KADM5_TL_DATA, KRB5_TL_HIST_KVNO_DIFF_SVC, 0, "Svc hist keys", "Historic keys allowed for service", 0 },
{ NULL }
{ NULL, 0, 0, 0, NULL, NULL, 0 }
};
struct field_info {
@@ -125,12 +125,17 @@ format_keytype(krb5_key_data *k, krb5_salt *def_salt, char *buf, size_t buf_len)
{
krb5_error_code ret;
char *s;
int aret;
buf[0] = '\0';
ret = krb5_enctype_to_string (context,
k->key_data_type[0],
&s);
if (ret)
asprintf (&s, "unknown(%d)", k->key_data_type[0]);
if (ret) {
aret = asprintf (&s, "unknown(%d)", k->key_data_type[0]);
if (aret == -1)
return; /* Nothing to do here, we have no way to pass the err */
}
strlcpy(buf, s, buf_len);
free(s);
@@ -140,21 +145,29 @@ format_keytype(krb5_key_data *k, krb5_salt *def_salt, char *buf, size_t buf_len)
k->key_data_type[0],
k->key_data_type[1],
&s);
if (ret)
asprintf (&s, "unknown(%d)", k->key_data_type[1]);
if (ret) {
aret = asprintf (&s, "unknown(%d)", k->key_data_type[1]);
if (aret == -1)
return; /* Again, nothing else to do... */
}
strlcat(buf, s, buf_len);
free(s);
aret = 0;
if (cmp_salt(def_salt, k) == 0)
s = strdup("");
else if(k->key_data_length[1] == 0)
s = strdup("()");
else
asprintf (&s, "(%.*s)", k->key_data_length[1],
(char *)k->key_data_contents[1]);
aret = asprintf (&s, "(%.*s)", k->key_data_length[1],
(char *)k->key_data_contents[1]);
if (aret == -1 || s == NULL)
return; /* Again, nothing else we can do... */
strlcat(buf, s, buf_len);
free(s);
asprintf (&s, "[%d]", k->key_data_kvno);
aret = asprintf (&s, "[%d]", k->key_data_kvno);
if (aret == -1)
return;
strlcat(buf, ")", buf_len);
strlcat(buf, s, buf_len);

View File

@@ -159,6 +159,7 @@ main(int argc, char **argv)
kadm5_config_params conf;
int optidx = 0;
int exit_status = 0;
int aret;
setprogname(argv[0]);
@@ -181,8 +182,8 @@ main(int argc, char **argv)
argv += optidx;
if (config_file == NULL) {
asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context));
if (config_file == NULL)
aret = asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context));
if (aret == -1)
errx(1, "out of memory");
}

View File

@@ -119,8 +119,10 @@ main(int argc, char **argv)
argv += optidx;
if (config_file == NULL) {
asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context));
if (config_file == NULL)
int aret;
aret = asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context));
if (aret == -1)
errx(1, "out of memory");
}

View File

@@ -45,6 +45,7 @@ stash(struct stash_options *opt, int argc, char **argv)
krb5_error_code ret;
krb5_enctype enctype;
hdb_master_key mkey;
int aret;
if(!local_flag) {
krb5_warnx(context, "stash is only available in local (-l) mode");
@@ -58,8 +59,8 @@ stash(struct stash_options *opt, int argc, char **argv)
}
if(opt->key_file_string == NULL) {
asprintf(&opt->key_file_string, "%s/m-key", hdb_db_dir(context));
if (opt->key_file_string == NULL)
aret = asprintf(&opt->key_file_string, "%s/m-key", hdb_db_dir(context));
if (aret == -1)
errx(1, "out of memory");
}
@@ -108,10 +109,16 @@ stash(struct stash_options *opt, int argc, char **argv)
}
{
char *new, *old;
asprintf(&old, "%s.old", opt->key_file_string);
asprintf(&new, "%s.new", opt->key_file_string);
if(old == NULL || new == NULL) {
char *new = NULL, *old = NULL;
int aret;
aret = asprintf(&old, "%s.old", opt->key_file_string);
if (aret == -1) {
ret = ENOMEM;
goto out;
}
aret = asprintf(&new, "%s.new", opt->key_file_string);
if (aret == -1) {
ret = ENOMEM;
goto out;
}