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

@@ -484,13 +484,14 @@ ad_get_cred(kadm5_ad_context *context, const char *password)
kadm5_ret_t ret;
krb5_ccache cc;
char *service;
int aret;
if (context->ccache)
return 0;
asprintf(&service, "%s/%s@%s", KRB5_TGS_NAME,
context->realm, context->realm);
if (service == NULL)
aret = asprintf(&service, "%s/%s@%s", KRB5_TGS_NAME,
context->realm, context->realm);
if (aret == -1 || service == NULL)
return ENOMEM;
ret = _kadm5_c_get_cred_cache(context->context,

View File

@@ -130,6 +130,7 @@ find_db_spec(kadm5_server_context *ctx)
krb5_context context = ctx->context;
struct hdb_dbinfo *info, *d;
krb5_error_code ret;
int aret;
if (ctx->config.realm) {
/* fetch the databases */
@@ -169,12 +170,24 @@ find_db_spec(kadm5_server_context *ctx)
if (ctx->config.dbname == NULL)
ctx->config.dbname = strdup(hdb_default_db(context));
if (ctx->config.acl_file == NULL)
asprintf(&ctx->config.acl_file, "%s/kadmind.acl", hdb_db_dir(context));
if (ctx->config.stash_file == NULL)
asprintf(&ctx->config.stash_file, "%s/m-key", hdb_db_dir(context));
if (ctx->log_context.log_file == NULL)
asprintf(&ctx->log_context.log_file, "%s/log", hdb_db_dir(context));
if (ctx->config.acl_file == NULL) {
aret = asprintf(&ctx->config.acl_file, "%s/kadmind.acl",
hdb_db_dir(context));
if (aret == -1)
return ENOMEM;
}
if (ctx->config.stash_file == NULL) {
aret = asprintf(&ctx->config.stash_file, "%s/m-key",
hdb_db_dir(context));
if (aret == -1)
return ENOMEM;
}
if (ctx->log_context.log_file == NULL) {
aret = asprintf(&ctx->log_context.log_file, "%s/log",
hdb_db_dir(context));
if (aret == -1)
return ENOMEM;
}
#ifndef NO_UNIX_SOCKETS
set_socket_name(context, &ctx->log_context.socket_name);

View File

@@ -96,9 +96,14 @@ kadm5_s_get_principals(void *server_handle,
d.exp = expression;
{
krb5_realm r;
int aret;
krb5_get_default_realm(context->context, &r);
asprintf(&d.exp2, "%s@%s", expression, r);
aret = asprintf(&d.exp2, "%s@%s", expression, r);
free(r);
if (aret == -1 || d.exp2 == NULL) {
return ENOMEM;
}
}
d.princs = NULL;
d.count = 0;

View File

@@ -479,11 +479,12 @@ kadm_connect(kadm5_client_context *ctx)
}
if (ctx->realm)
asprintf(&service_name, "%s@%s", KADM5_ADMIN_SERVICE, ctx->realm);
error = asprintf(&service_name, "%s@%s", KADM5_ADMIN_SERVICE,
ctx->realm);
else
asprintf(&service_name, "%s", KADM5_ADMIN_SERVICE);
error = asprintf(&service_name, "%s", KADM5_ADMIN_SERVICE);
if (service_name == NULL) {
if (error == -1 || service_name == NULL) {
freeaddrinfo (ai);
rk_closesocket(s);
krb5_clear_error_message(context);

View File

@@ -47,11 +47,12 @@ get_kadmin_context(const char *config_file, char *realm)
krb5_error_code ret;
void *kadm_handle;
char **files;
int aret;
if (config_file == NULL) {
char *file;
asprintf(&file, "%s/kdc.conf", hdb_db_dir(context));
if (file == NULL)
aret = asprintf(&file, "%s/kdc.conf", hdb_db_dir(context));
if (aret == -1 || file == NULL)
errx(1, "out of memory");
config_file = file;
}

View File

@@ -623,24 +623,25 @@ open_stats(krb5_context context)
{
char *statfile = NULL;
const char *fn;
FILE *f;
int ret;
if (slave_stats_file)
fn = slave_stats_file;
else {
asprintf(&statfile, "%s/slaves-stats", hdb_db_dir(context));
ret = asprintf(&statfile, "%s/slaves-stats", hdb_db_dir(context));
if (ret == -1)
return NULL;
fn = krb5_config_get_string_default(context,
NULL,
statfile,
"kdc",
"iprop-stats",
NULL);
}
f = fopen(fn, "w");
if (statfile)
free(statfile);
return f;
}
if (fn == NULL)
return NULL;
return fopen(fn, "w");
}
static void
@@ -776,6 +777,7 @@ main(int argc, char **argv)
uint32_t current_version = 0, old_version = 0;
krb5_keytab keytab;
char **files;
int aret;
(void) krb5_program_setup(&context, argc, argv, args, num_args, NULL);
@@ -789,8 +791,8 @@ main(int argc, char **argv)
setup_signal();
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 || config_file == NULL)
errx(1, "out of memory");
}
@@ -811,8 +813,13 @@ main(int argc, char **argv)
krb5_errx (context, 1, "couldn't parse time: %s", slave_time_missing);
#ifdef SUPPORT_DETACH
if (detach_from_console)
daemon(0, 0);
if (detach_from_console) {
aret = daemon(0, 0);
if (aret == -1) {
/* not much to do if detaching fails... */
krb5_err(context, 1, aret, "failed to daemon(3)ise");
}
}
#endif
pidfile (NULL);
krb5_openlog (context, "ipropd-master", &log_facility);

View File

@@ -107,6 +107,7 @@ get_creds(krb5_context context, const char *keytab_str,
krb5_creds creds;
char *server;
char keytab_buf[256];
int aret;
if (keytab_str == NULL) {
ret = krb5_kt_default_name (context, keytab_buf, sizeof(keytab_buf));
@@ -127,8 +128,8 @@ get_creds(krb5_context context, const char *keytab_str,
ret = krb5_get_init_creds_opt_alloc(context, &init_opts);
if (ret) krb5_err(context, 1, ret, "krb5_get_init_creds_opt_alloc");
asprintf (&server, "%s/%s", IPROP_NAME, serverhost);
if (server == NULL)
aret = asprintf (&server, "%s/%s", IPROP_NAME, serverhost);
if (aret == -1 || server == NULL)
krb5_errx (context, 1, "malloc: no memory");
ret = krb5_get_init_creds_keytab(context, &creds, client, keytab,
@@ -374,7 +375,9 @@ receive_everything (krb5_context context, int fd,
krb5_warnx(context, "receive complete database");
asprintf(&dbname, "%s-NEW", server_context->db->hdb_name);
ret = asprintf(&dbname, "%s-NEW", server_context->db->hdb_name);
if (ret == -1)
krb5_err(context, 1, ENOMEM, "asprintf");
ret = hdb_create(context, &mydb, dbname);
if(ret)
krb5_err(context,1, ret, "hdb_create");
@@ -563,6 +566,7 @@ main(int argc, char **argv)
time_t reconnect_max;
time_t reconnect;
time_t before = 0;
int aret;
const char *master;
@@ -615,8 +619,13 @@ main(int argc, char **argv)
slave_status(context, status_file, "bootstrapping\n");
#ifdef SUPPORT_DETACH
if (detach_from_console)
daemon(0, 0);
if (detach_from_console){
aret = daemon(0, 0);
if (aret == -1) {
/* not much to do if detaching fails... */
krb5_err(context, 1, aret, "failed to daemon(3)ise");
}
}
#endif
pidfile (NULL);
krb5_openlog (context, "ipropd-slave", &log_facility);

View File

@@ -1015,9 +1015,13 @@ static HEIMDAL_MUTEX signal_mutex = HEIMDAL_MUTEX_INITIALIZER;
const char *
kadm5_log_signal_socket(krb5_context context)
{
int ret = 0;
HEIMDAL_MUTEX_lock(&signal_mutex);
if (!default_signal)
asprintf(&default_signal, "%s/signal", hdb_db_dir(context));
ret = asprintf(&default_signal, "%s/signal", hdb_db_dir(context));
if (ret == -1)
default_signal = NULL;
HEIMDAL_MUTEX_unlock(&signal_mutex);
return krb5_config_get_string_default(context,

View File

@@ -42,10 +42,10 @@ static char *principal;
static char *password;
static struct getargs args[] = {
{ "principal", 0, arg_string, &principal },
{ "password", 0, arg_string, &password },
{ "version", 0, arg_flag, &version_flag },
{ "help", 0, arg_flag, &help_flag }
{ "principal", 0, arg_string, &principal, NULL, NULL },
{ "password", 0, arg_string, &password, NULL, NULL },
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
{ "help", 0, arg_flag, &help_flag, NULL, NULL }
};
int num_args = sizeof(args) / sizeof(args[0]);