From 3f43a36fba5998174e66c5576f425e633b87970f Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Mon, 14 Mar 2011 20:34:59 +0000 Subject: [PATCH] Resolve a few miscellaneous warnings git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24703 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/builtin/enc_provider/aes.c | 2 +- src/lib/crypto/krb/crypto_length.c | 2 +- src/lib/kadm5/logger.c | 2 +- src/lib/kadm5/misc_free.c | 5 ----- src/lib/kdb/kdb_convert.c | 14 ++++++++------ src/lib/kdb/kdb_log.c | 10 +++++++--- src/lib/krb5/asn.1/asn1_k_decode_macros.h | 2 +- src/lib/krb5/krb/bld_princ.c | 21 +++++++++++---------- src/lib/krb5/krb/chpw.c | 2 +- src/lib/krb5/krb/get_creds.c | 2 -- src/lib/krb5/krb/gic_pwd.c | 2 +- src/lib/krb5/krb/ser_actx.c | 2 +- src/lib/krb5/os/dnsglue.c | 4 ++-- src/lib/krb5/os/sendto_kdc.c | 2 -- 14 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/lib/crypto/builtin/enc_provider/aes.c b/src/lib/crypto/builtin/enc_provider/aes.c index 1809cd09a..b46680a9e 100644 --- a/src/lib/crypto/builtin/enc_provider/aes.c +++ b/src/lib/crypto/builtin/enc_provider/aes.c @@ -61,7 +61,7 @@ xorblock(unsigned char *out, const unsigned char *in) int z; for (z = 0; z < BLOCK_SIZE/4; z++) { unsigned char *outptr = &out[z*4]; - unsigned char *inptr = &in[z*4]; + const unsigned char *inptr = &in[z*4]; /* * Use unaligned accesses. On x86, this will probably still be faster * than multiple byte accesses for unaligned data, and for aligned data diff --git a/src/lib/crypto/krb/crypto_length.c b/src/lib/crypto/krb/crypto_length.c index b33235dc4..a621423a1 100644 --- a/src/lib/crypto/krb/crypto_length.c +++ b/src/lib/crypto/krb/crypto_length.c @@ -42,7 +42,7 @@ krb5_c_crypto_length(krb5_context context, krb5_enctype enctype, *size = 0; break; case KRB5_CRYPTO_TYPE_DATA: - *size = (size_t)~0; /* match Heimdal */ + *size = (unsigned int)~0; /* match Heimdal */ break; case KRB5_CRYPTO_TYPE_HEADER: case KRB5_CRYPTO_TYPE_PADDING: diff --git a/src/lib/kadm5/logger.c b/src/lib/kadm5/logger.c index cddb620a3..e45f6b155 100644 --- a/src/lib/kadm5/logger.c +++ b/src/lib/kadm5/logger.c @@ -200,7 +200,7 @@ klog_com_err_proc(const char *whoami, long int code, const char *format, va_list /* If reporting an error message, separate it. */ if (code) { - char *emsg; + const char *emsg; outbuf[sizeof(outbuf) - 1] = '\0'; emsg = krb5_get_error_message (err_context, code); diff --git a/src/lib/kadm5/misc_free.c b/src/lib/kadm5/misc_free.c index 17c8cccac..0f611cce6 100644 --- a/src/lib/kadm5/misc_free.c +++ b/src/lib/kadm5/misc_free.c @@ -1,13 +1,8 @@ /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved - * - * $Header$ */ -#if !defined(lint) && !defined(__CODECENTER__) -static char *rcsid = "$Header$"; -#endif #include #include #include "server_internal.h" diff --git a/src/lib/kdb/kdb_convert.c b/src/lib/kdb/kdb_convert.c index 2799b443b..7e97a9eef 100644 --- a/src/lib/kdb/kdb_convert.c +++ b/src/lib/kdb/kdb_convert.c @@ -248,7 +248,8 @@ set_from_utf8str(krb5_data *d, utf8str_t u) static krb5_principal conv_princ_2db(krb5_context context, kdbe_princ_t *kdbe_princ) { - int i; + unsigned int i; + int j; krb5_principal princ; kdbe_data_t *components; @@ -275,10 +276,10 @@ conv_princ_2db(krb5_context context, kdbe_princ_t *kdbe_princ) princ->data[i].data = NULL; princ->length = (krb5_int32)kdbe_princ->k_components.k_components_len; - for (i = 0; i < princ->length; i++) { - princ->data[i].magic = components[i].k_magic; - set_from_utf8str(&princ->data[i], components[i].k_data); - if (princ->data[i].data == NULL) + for (j = 0; j < princ->length; j++) { + princ->data[j].magic = components[j].k_magic; + set_from_utf8str(&princ->data[j], components[j].k_data); + if (princ->data[j].data == NULL) goto error; } @@ -822,7 +823,8 @@ ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates) { kdb_incr_update_t *upd; - int i, j, k, cnt; + unsigned int i, j; + int k, cnt; if (updates == NULL) return; diff --git a/src/lib/kdb/kdb_log.c b/src/lib/kdb/kdb_log.c index 0842439a3..c254ab27d 100644 --- a/src/lib/kdb/kdb_log.c +++ b/src/lib/kdb/kdb_log.c @@ -19,6 +19,10 @@ #include "kdb_log.h" #include "kdb5int.h" +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + /* * This modules includes all the necessary functions that create and * modify the Kerberos principal update and header logs. @@ -602,7 +606,7 @@ ulog_map(krb5_context context, const char *logname, uint32_t ulogentries, PROT_READ+PROT_WRITE, MAP_SHARED, ulogfd, 0); } - if ((int)(ulog) == -1) { + if (ulog == MAP_FAILED) { /* * Can't map update log file to memory */ @@ -901,7 +905,7 @@ ulog_set_role(krb5_context ctx, iprop_role role) */ static int extend_file_to(int fd, uint_t new_size) { - int current_offset; + off_t current_offset; static const char zero[512] = { 0, }; current_offset = lseek(fd, 0, SEEK_END); @@ -911,7 +915,7 @@ static int extend_file_to(int fd, uint_t new_size) errno = EINVAL; return -1; } - while (current_offset < new_size) { + while (current_offset < (off_t)new_size) { int write_size, wrote_size; write_size = new_size - current_offset; if (write_size > 512) diff --git a/src/lib/krb5/asn.1/asn1_k_decode_macros.h b/src/lib/krb5/asn.1/asn1_k_decode_macros.h index 4160b10d6..e3e7fc08b 100644 --- a/src/lib/krb5/asn.1/asn1_k_decode_macros.h +++ b/src/lib/krb5/asn.1/asn1_k_decode_macros.h @@ -351,7 +351,7 @@ asn1_get_eoc_tag (asn1buf *buf) * Like end_sequence_of(), but uses the different (non-shadowing) * variable names. */ -static asn1_error_code +static inline asn1_error_code end_sequence_of_no_tagvars_helper(asn1buf *buf, asn1buf *seqbufp, int seqofindef) { diff --git a/src/lib/krb5/krb/bld_princ.c b/src/lib/krb5/krb/bld_princ.c index 4b979a391..8c17ab382 100644 --- a/src/lib/krb5/krb/bld_princ.c +++ b/src/lib/krb5/krb/bld_princ.c @@ -151,21 +151,22 @@ krb5_build_principal_alloc_va(krb5_context context, va_list ap) { krb5_error_code retval = 0; + krb5_principal p; + char *first; - krb5_principal p = malloc(sizeof(krb5_principal_data)); - if (!p) { retval = ENOMEM; } - - if (!retval) { - retval = krb5_build_principal_va(context, p, rlen, realm, ap); - } + p = malloc(sizeof(krb5_principal_data)); + if (p == NULL) + return ENOMEM; - if (!retval) { - *princ = p; - } else { + first = va_arg(ap, char *); + retval = krb5int_build_principal_va(context, p, rlen, realm, first, ap); + if (retval) { free(p); + return retval; } - return retval; + *princ = p; + return 0; } krb5_error_code KRB5_CALLCONV_C diff --git a/src/lib/krb5/krb/chpw.c b/src/lib/krb5/krb/chpw.c index 1488f627e..3f359ba71 100644 --- a/src/lib/krb5/krb/chpw.c +++ b/src/lib/krb5/krb/chpw.c @@ -78,7 +78,7 @@ krb5int_rd_chpw_rep(krb5_context context, krb5_auth_context auth_context, krb5_data *packet, int *result_code, krb5_data *result_data) { char *ptr; - int plen, vno; + unsigned int plen, vno; krb5_data ap_rep; krb5_ap_rep_enc_part *ap_rep_enc; krb5_error_code ret; diff --git a/src/lib/krb5/krb/get_creds.c b/src/lib/krb5/krb/get_creds.c index dcce7ed08..afa34c2d8 100644 --- a/src/lib/krb5/krb/get_creds.c +++ b/src/lib/krb5/krb/get_creds.c @@ -417,8 +417,6 @@ seen_realm_before(krb5_context context, krb5_tkt_creds_context ctx, static krb5_error_code complete(krb5_context context, krb5_tkt_creds_context ctx) { - krb5_error_code code; - TRACE_TKT_CREDS_COMPLETE(context, ctx->reply_creds->server); /* Note the authdata we asked for in the output creds. */ diff --git a/src/lib/krb5/krb/gic_pwd.c b/src/lib/krb5/krb/gic_pwd.c index 1fdc814d2..f76f5be00 100644 --- a/src/lib/krb5/krb/gic_pwd.c +++ b/src/lib/krb5/krb/gic_pwd.c @@ -62,7 +62,7 @@ krb5_get_as_key_password(krb5_context context, return(ret); } - if ((salt->length == -1 || salt->length == SALT_TYPE_AFS_LENGTH) && (salt->data == NULL)) { + if (salt->length == SALT_TYPE_AFS_LENGTH && salt->data == NULL) { if ((ret = krb5_principal2salt(context, client, &defsalt))) return(ret); diff --git a/src/lib/krb5/krb/ser_actx.c b/src/lib/krb5/krb/ser_actx.c index 4ac81128a..b366ff343 100644 --- a/src/lib/krb5/krb/ser_actx.c +++ b/src/lib/krb5/krb/ser_actx.c @@ -230,7 +230,7 @@ krb5_auth_context_externalize(krb5_context kcontext, krb5_pointer arg, krb5_octe /* Convert to signed 32 bit integer */ obuf32 = obuf; - if (kret == 0 && obuf != obuf32) + if (kret == 0 && obuf > KRB5_INT32_MAX) kret = EINVAL; if (!kret) (void) krb5_ser_pack_int32(obuf32, &bp, &remain); diff --git a/src/lib/krb5/os/dnsglue.c b/src/lib/krb5/os/dnsglue.c index 826e15952..6d1189699 100644 --- a/src/lib/krb5/os/dnsglue.c +++ b/src/lib/krb5/os/dnsglue.c @@ -184,8 +184,8 @@ krb5int_dns_nextans(struct krb5int_dns_state *ds, if (len < 0) return -1; ds->cur_ans++; - if (ds->nclass == ns_rr_class(rr) - && ds->ntype == ns_rr_type(rr)) { + if (ds->nclass == (int)ns_rr_class(rr) + && ds->ntype == (int)ns_rr_type(rr)) { *pp = ns_rr_rdata(rr); *lenp = ns_rr_rdlen(rr); return 0; diff --git a/src/lib/krb5/os/sendto_kdc.c b/src/lib/krb5/os/sendto_kdc.c index 058b6d1ed..ed5d62826 100644 --- a/src/lib/krb5/os/sendto_kdc.c +++ b/src/lib/krb5/os/sendto_kdc.c @@ -1125,8 +1125,6 @@ service_fds(krb5_context context, struct select_state *selstate, int interval, e = 0; while (selstate->nfds > 0) { - unsigned int i; - e = krb5int_cm_call_select(selstate, seltemp, &selret); if (e == EINTR) continue; -- 2.26.2