Fix warnings (some bugs, some spurious)

Many spurious VC warnings not quieted though.
This commit is contained in:
Nicolas Williams
2020-03-12 00:42:33 -05:00
parent f3e6c4ffd4
commit 64d5f86ec3
20 changed files with 38 additions and 36 deletions

View File

@@ -90,9 +90,8 @@ heim_store_string_to_reg_value(heim_context context,
const char *separator)
{
LONG rcode;
DWORD dwData;
int dwData;
BYTE static_buffer[16384];
BYTE *pbuffer = &static_buffer[0];
if (data == NULL)
{

View File

@@ -1231,7 +1231,7 @@ gss_release_cred_by_mech(
GSSAPI_LIB_FUNCTION void GSSAPI_LIB_CALL
gss_set_log_function(void *ctx, void (*func)(void * ctx, int level, const char *fmt, va_list));
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_FUNCTION
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
gss_destroy_cred(OM_uint32 *minor_status,
gss_cred_id_t *cred_handle);

View File

@@ -76,13 +76,13 @@ add_env(OM_uint32 *minor,
static OM_uint32
set_proc(OM_uint32 *minor, gss_buffer_set_t env)
{
size_t i;
/*
* XXX On systems with setpag(), call setpag(). On WIN32... create a
* session, set the access token, ...?
*/
#ifndef WIN32
size_t i;
for (i = 0; i < env->count; i++)
putenv(env->elements[i].value);
#endif

View File

@@ -196,8 +196,8 @@ _gss_mg_decode_le_uint16(const void *ptr, uint16_t *n)
void
_gss_mg_encode_be_uint16(uint16_t n, uint8_t *p)
{
p[0] = (n >> 24) & 0xFF;
p[1] = (n >> 16) & 0xFF;
p[0] = (n >> 8) & 0xFF;
p[1] = (n >> 0) & 0xFF;
}
void

View File

@@ -619,7 +619,7 @@ mk_temp(const char *fn, char **tfn)
return -1;
}
if (p = strrchr(ds, '\\') == NULL) {
if ((p = strrchr(ds, '\\')) == NULL) {
ret = asprintf(tfn, ".%s-XXXXXX", ds); /* XXX can't happen */
} else {
*(p++) = '\0';

View File

@@ -368,7 +368,7 @@ dsstringprep(const DirectoryString *ds, uint32_t **rname, size_t *rlen)
{
wind_profile_flags flags;
size_t i, len;
int ret;
int ret = 0;
uint32_t *name;
*rname = NULL;
@@ -418,7 +418,10 @@ dsstringprep(const DirectoryString *ds, uint32_t **rname, size_t *rlen)
/* try a couple of times to get the length right, XXX gross */
for (i = 0; i < 4; i++) {
*rlen = *rlen * 2;
*rname = malloc(*rlen * sizeof((*rname)[0]));
if ((*rname = malloc(*rlen * sizeof((*rname)[0]))) == NULL) {
ret = ENOMEM;
break;
}
ret = wind_stringprep(name, len, *rname, rlen, flags);
if (ret == WIND_ERR_OVERRUN) {

View File

@@ -636,7 +636,7 @@ hx509_request_to_pkcs10(hx509_context context,
if (ret == 0)
ret = get_exts(context, req, &exts);
if (ret == 0 && exts.len) {
Attribute *a;
Attribute *a = NULL; /* Quiet VC */
heim_any extns;
r.certificationRequestInfo.attributes =
@@ -655,7 +655,7 @@ hx509_request_to_pkcs10(hx509_context context,
if (ret == 0)
ASN1_MALLOC_ENCODE(Extensions, extns.data, extns.length,
&exts, &size, ret);
if (ret == 0)
if (ret == 0 && a)
ret = der_copy_oid(&asn1_oid_id_pkcs9_extReq, &a->type);
if (ret == 0)
ret = add_AttributeValues(&a->value, &extns);

View File

@@ -1064,8 +1064,6 @@ get_left(kadm5_server_context *server_context, slave *s, krb5_storage *sp,
*/
}
return left;
err:
flock(log_fd, LOCK_UN);
return -1;
@@ -1190,7 +1188,6 @@ send_diffs(kadm5_server_context *server_context, slave *s, int log_fd,
sp = krb5_storage_from_data(&data);
if (sp == NULL) {
krb5_err(context, IPROPD_RESTART_SLOW, ENOMEM, "out of memory");
krb5_warnx(context, "send_diffs: krb5_storage_from_data");
return;
}
krb5_store_uint32(sp, FOR_YOU);

View File

@@ -450,7 +450,7 @@ acc_get_name(krb5_context context,
const char **colname,
const char **subsidiary)
{
krb5_error_code ret;
krb5_error_code ret = 0;
krb5_acc *a = ACACHE(id);
int32_t error;
@@ -486,7 +486,7 @@ acc_get_name(krb5_context context,
if (colname)
*colname = "";
if (subsidiary)
*subsidiary = a->cache_subsidiary;
*subsidiary = a->cache_subsidiary;
return ret;
}

View File

@@ -1895,7 +1895,7 @@ KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_cccol_cursor_next(krb5_context context, krb5_cccol_cursor cursor,
krb5_ccache *cache)
{
krb5_error_code ret;
krb5_error_code ret = 0;
*cache = NULL;
@@ -2238,7 +2238,7 @@ _get_default_cc_name_from_registry(krb5_context context, HKEY hkBase)
if (code != ERROR_SUCCESS)
return NULL;
ccname = heim_parse_reg_value_as_string(context, hk_k5, "ccname",
ccname = heim_parse_reg_value_as_string(context->hcontext, hk_k5, "ccname",
REG_NONE, 0);
RegCloseKey(hk_k5);
@@ -2278,7 +2278,7 @@ _krb5_set_default_cc_name_to_registry(krb5_context context, krb5_ccache id)
if (ret < 0)
goto cleanup;
ret = heim_store_string_to_reg_value(context, hk_k5, "ccname",
ret = heim_store_string_to_reg_value(context->hcontext, hk_k5, "ccname",
REG_SZ, ccname, -1, 0);
cleanup:

View File

@@ -243,18 +243,15 @@ init_context_from_config_file(krb5_context context)
context->configured_default_cc_name = NULL;
tmp = secure_getenv("KRB5_TRACE");
if (tmp)
heim_add_debug_dest(context->hcontext, "libkrb5", tmp);
s = krb5_config_get_strings(context, NULL, "logging", "krb5", NULL);
if (tmp || s) {
if (s) {
char **p;
if (s) {
for (p = s; *p; p++)
heim_add_debug_dest(context->hcontext, "libkrb5", *p);
krb5_config_free_strings(s);
}
if (tmp)
for (p = s; *p; p++)
heim_add_debug_dest(context->hcontext, "libkrb5", *p);
krb5_config_free_strings(s);
}
tmp = krb5_config_get_string(context, NULL, "libdefaults",

View File

@@ -760,7 +760,7 @@ mk_kx509_req(krb5_context context,
HMAC_CTX ctx;
const char *hostname;
char *start_realm = NULL;
size_t len;
size_t len = 0;
krb5_data_zero(&pre_req);
memset(&spki, 0, sizeof(spki));

View File

@@ -104,7 +104,7 @@ krb5_plugin_register(krb5_context context,
KRB5_LIB_FUNCTION void KRB5_LIB_CALL
_krb5_load_plugins(krb5_context context, const char *name, const char **paths)
{
return heim_load_plugins(context->hcontext, name, paths);
heim_load_plugins(context->hcontext, name, paths);
}
/**

View File

@@ -384,7 +384,7 @@ scc_alloc(krb5_context context,
if ((subsidiary = strrchr(s->file, ':'))) {
#ifdef WIN32
if (subsidiary == &s->file + 1)
if (subsidiary == s->file + 1)
subsidiary = NULL;
else
#endif

View File

@@ -112,6 +112,7 @@ krb5_storage_from_socket(krb5_socket_t sock_in)
#ifdef _WIN32
WSAPROTOCOL_INFO info;
sock = rk_INVALID_SOCKET;
if (WSADuplicateSocket(sock_in, GetCurrentProcessId(), &info) == 0)
{

View File

@@ -34,6 +34,11 @@
#include "krb5_locl.h"
#include "store-int.h"
#ifndef HAVE_FSEEKO
#define fseeko fseek
#define ftello ftell
#endif
typedef struct stdio_storage {
FILE *f;
off_t pos;

View File

@@ -68,7 +68,7 @@ static void
do_readprocauxv(void)
{
char *p = (void *)auxv;
ssize_t bytes;
ssize_t bytes = 0;
size_t sz = sizeof(auxv) - sizeof(auxv[0]); /* leave terminator */
int save_errno = errno;
int fd;

View File

@@ -319,8 +319,8 @@ roken_get_loginname(char *user, size_t usersz)
if (errno != ENOENT)
return NULL;
#endif
#endif
#endif
errno = 0;
return NULL;
#endif
}

View File

@@ -448,7 +448,7 @@ rk_wcsdup(const unsigned short *);
#ifndef HAVE_MEMMEM
#define memmem rk_smemmem
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL memmem(const char *);
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL memmem(const void *, size_t, const void *, size_t);
#endif
#ifdef HAVE_WINSOCK

View File

@@ -41,7 +41,7 @@ ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
sleep(unsigned int seconds)
{
if (SleepEx(1000 * (DWORD) seconds, FALSE) != 0)
return -1;
return 1; /* XXX Should get time before and after */
return 0;
}
@@ -50,6 +50,6 @@ ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
usleep(unsigned int useconds)
{
if (SleepEx((DWORD)(useconds / 1000), FALSE) != 0)
return -1;
return 1000; /* XXX Should get time before and after */
return 0;
}