diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/conf/conf_api.c | 23 | ||||
-rw-r--r-- | crypto/err/err.c | 45 | ||||
-rw-r--r-- | crypto/mem_dbg.c | 32 | ||||
-rw-r--r-- | crypto/objects/o_names.c | 23 | ||||
-rw-r--r-- | crypto/objects/obj_dat.c | 14 |
5 files changed, 75 insertions, 62 deletions
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c index 64bbd971ab..8216e64525 100644 --- a/crypto/conf/conf_api.c +++ b/crypto/conf/conf_api.c @@ -70,11 +70,12 @@ static void value_free_hash(CONF_VALUE *a, LHASH *conf); static void value_free_stack(CONF_VALUE *a,LHASH *conf); -static unsigned long hash(CONF_VALUE *v); -static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); - -static IMPLEMENT_LHASH_HASH_FN(hash, CONF_VALUE *) -static IMPLEMENT_LHASH_COMP_FN(cmp_conf, CONF_VALUE *) +/* We don't use function pointer casting or wrapper functions - but cast each + * callback parameter inside the callback functions. */ +/* static unsigned long hash(CONF_VALUE *v); */ +static unsigned long hash(void *v_void); +/* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */ +static int cmp_conf(void *a_void,void *b_void); /* Up until OpenSSL 0.9.5a, this was get_section */ CONF_VALUE *_CONF_get_section(CONF *conf, char *section) @@ -184,8 +185,7 @@ int _CONF_new_data(CONF *conf) return 0; } if (conf->data == NULL) - if ((conf->data = lh_new(LHASH_HASH_FN(hash), - LHASH_COMP_FN(cmp_conf))) == NULL) + if ((conf->data = lh_new(hash, cmp_conf)) == NULL) { return 0; } @@ -238,14 +238,19 @@ static void value_free_stack(CONF_VALUE *a, LHASH *conf) OPENSSL_free(a); } -static unsigned long hash(CONF_VALUE *v) +/* static unsigned long hash(CONF_VALUE *v) */ +static unsigned long hash(void *v_void) { + CONF_VALUE *v = (CONF_VALUE *)v_void; return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); } -static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) +/* static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) */ +static int cmp_conf(void *a_void, void *b_void) { int i; + CONF_VALUE *a = (CONF_VALUE *)a_void; + CONF_VALUE *b = (CONF_VALUE *)b_void; if (a->section != b->section) { diff --git a/crypto/err/err.c b/crypto/err/err.c index 3b4de23775..48eed688a6 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -123,18 +123,17 @@ static LHASH *error_hash=NULL; static LHASH *thread_hash=NULL; -static unsigned long err_hash(ERR_STRING_DATA *a); -static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); -static unsigned long pid_hash(ERR_STATE *pid); -static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); +/* static unsigned long err_hash(ERR_STRING_DATA *a); */ +static unsigned long err_hash(void *a_void); +/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); */ +static int err_cmp(void *a_void, void *b_void); +/* static unsigned long pid_hash(ERR_STATE *pid); */ +static unsigned long pid_hash(void *pid_void); +/* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */ +static int pid_cmp(void *a_void,void *pid_void); static unsigned long get_error_values(int inc,const char **file,int *line, const char **data,int *flags); -static IMPLEMENT_LHASH_HASH_FN(err_hash, ERR_STRING_DATA *) -static IMPLEMENT_LHASH_COMP_FN(err_cmp, ERR_STRING_DATA *) -static IMPLEMENT_LHASH_HASH_FN(pid_hash, ERR_STATE *) -static IMPLEMENT_LHASH_COMP_FN(pid_cmp, ERR_STATE *) - static void ERR_STATE_free(ERR_STATE *s); #ifndef NO_ERR static ERR_STRING_DATA ERR_str_libraries[]= @@ -322,8 +321,7 @@ void ERR_load_strings(int lib, ERR_STRING_DATA *str) if (error_hash == NULL) { CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); - error_hash=lh_new(LHASH_HASH_FN(err_hash), - LHASH_COMP_FN(err_cmp)); + error_hash=lh_new(err_hash, err_cmp); if (error_hash == NULL) { CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); @@ -627,28 +625,34 @@ const char *ERR_reason_error_string(unsigned long e) return((p == NULL)?NULL:p->string); } -static unsigned long err_hash(ERR_STRING_DATA *a) +/* static unsigned long err_hash(ERR_STRING_DATA *a) */ +static unsigned long err_hash(void *a_void) { unsigned long ret,l; - l=a->error; + l=((ERR_STRING_DATA *)a_void)->error; ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); return(ret^ret%19*13); } -static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) +/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */ +static int err_cmp(void *a_void, void *b_void) { - return((int)(a->error-b->error)); + return((int)(((ERR_STRING_DATA *)a_void)->error - + ((ERR_STRING_DATA *)b_void)->error)); } -static unsigned long pid_hash(ERR_STATE *a) +/* static unsigned long pid_hash(ERR_STATE *a) */ +static unsigned long pid_hash(void *a_void) { - return(a->pid*13); + return(((ERR_STATE *)a_void)->pid*13); } -static int pid_cmp(ERR_STATE *a, ERR_STATE *b) +/* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */ +static int pid_cmp(void *a_void, void *b_void) { - return((int)((long)a->pid - (long)b->pid)); + return((int)((long)((ERR_STATE *)a_void)->pid - + (long)((ERR_STATE *)b_void)->pid)); } void ERR_remove_state(unsigned long pid) @@ -713,8 +717,7 @@ ERR_STATE *ERR_get_state(void) /* no entry yet in thread_hash for current thread - * thus, it may have changed since we last looked at it */ if (thread_hash == NULL) - thread_hash = lh_new(LHASH_HASH_FN(pid_hash), - LHASH_COMP_FN(pid_cmp)); + thread_hash = lh_new(pid_hash, pid_cmp); if (thread_hash == NULL) thread_state_exists = 0; /* allocation error */ else diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index 56ce7dddea..8e48e25fbd 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -219,42 +219,40 @@ long CRYPTO_dbg_get_options(void) return options; } -static int mem_cmp(MEM *a, MEM *b) +/* static int mem_cmp(MEM *a, MEM *b) */ +static int mem_cmp(void *a_void, void *b_void) { - return((char *)a->addr - (char *)b->addr); + return((char *)((MEM *)a_void)->addr - (char *)((MEM *)b_void)->addr); } -static unsigned long mem_hash(MEM *a) +/* static unsigned long mem_hash(MEM *a) */ +static unsigned long mem_hash(void *a_void) { unsigned long ret; - ret=(unsigned long)a->addr; + ret=(unsigned long)((MEM *)a_void)->addr; ret=ret*17851+(ret>>14)*7+(ret>>4)*251; return(ret); } -static IMPLEMENT_LHASH_HASH_FN(mem_hash, MEM *) -static IMPLEMENT_LHASH_COMP_FN(mem_cmp, MEM *) - -static int app_info_cmp(APP_INFO *a, APP_INFO *b) +/* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */ +static int app_info_cmp(void *a_void, void *b_void) { - return(a->thread != b->thread); + return(((APP_INFO *)a_void)->thread != ((APP_INFO *)b_void)->thread); } -static unsigned long app_info_hash(APP_INFO *a) +/* static unsigned long app_info_hash(APP_INFO *a) */ +static unsigned long app_info_hash(void *a_void) { unsigned long ret; - ret=(unsigned long)a->thread; + ret=(unsigned long)((APP_INFO *)a_void)->thread; ret=ret*17851+(ret>>14)*7+(ret>>4)*251; return(ret); } -static IMPLEMENT_LHASH_HASH_FN(app_info_hash, APP_INFO *) -static IMPLEMENT_LHASH_COMP_FN(app_info_cmp, APP_INFO *) - static APP_INFO *pop_info(void) { APP_INFO tmp; @@ -308,8 +306,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line) } if (amih == NULL) { - if ((amih=lh_new(LHASH_HASH_FN(app_info_hash), - LHASH_COMP_FN(app_info_cmp))) == NULL) + if ((amih=lh_new(app_info_hash, app_info_cmp)) == NULL) { OPENSSL_free(ami); ret=0; @@ -401,8 +398,7 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, } if (mh == NULL) { - if ((mh=lh_new(LHASH_HASH_FN(mem_hash), - LHASH_COMP_FN(mem_cmp))) == NULL) + if ((mh=lh_new(mem_hash, mem_cmp)) == NULL) { OPENSSL_free(addr); OPENSSL_free(m); diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index ccf3a18726..a5b1aacd66 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -24,18 +24,20 @@ IMPLEMENT_STACK_OF(NAME_FUNCS) static STACK_OF(NAME_FUNCS) *name_funcs_stack; -static unsigned long obj_name_hash(OBJ_NAME *a); -static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); +/* The LHASH callbacks now use the raw "void *" prototypes and do per-variable + * casting in the functions. This prevents function pointer casting without the + * need for macro-generated wrapper functions. */ -static IMPLEMENT_LHASH_HASH_FN(obj_name_hash, OBJ_NAME *) -static IMPLEMENT_LHASH_COMP_FN(obj_name_cmp, OBJ_NAME *) +/* static unsigned long obj_name_hash(OBJ_NAME *a); */ +static unsigned long obj_name_hash(void *a_void); +/* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */ +static int obj_name_cmp(void *a_void,void *b_void); int OBJ_NAME_init(void) { if (names_lh != NULL) return(1); MemCheck_off(); - names_lh=lh_new(LHASH_HASH_FN(obj_name_hash), - LHASH_COMP_FN(obj_name_cmp)); + names_lh=lh_new(obj_name_hash, obj_name_cmp); MemCheck_on(); return(names_lh != NULL); } @@ -85,9 +87,12 @@ int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), return(ret); } -static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) +/* static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) */ +static int obj_name_cmp(void *a_void, void *b_void) { int ret; + OBJ_NAME *a = (OBJ_NAME *)a_void; + OBJ_NAME *b = (OBJ_NAME *)b_void; ret=a->type-b->type; if (ret == 0) @@ -104,9 +109,11 @@ static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) return(ret); } -static unsigned long obj_name_hash(OBJ_NAME *a) +/* static unsigned long obj_name_hash(OBJ_NAME *a) */ +static unsigned long obj_name_hash(void *a_void) { unsigned long ret; + OBJ_NAME *a = (OBJ_NAME *)a_void; if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) { diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index 6eb9f48861..0057da29bd 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -108,12 +108,14 @@ static int ln_cmp(const void *a, const void *b) return(strcmp((*ap)->ln,(*bp)->ln)); } -static unsigned long add_hash(ADDED_OBJ *ca) +/* static unsigned long add_hash(ADDED_OBJ *ca) */ +static unsigned long add_hash(void *ca_void) { ASN1_OBJECT *a; int i; unsigned long ret=0; unsigned char *p; + ADDED_OBJ *ca = (ADDED_OBJ *)ca_void; a=ca->obj; switch (ca->type) @@ -142,10 +144,13 @@ static unsigned long add_hash(ADDED_OBJ *ca) return(ret); } -static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) +/* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */ +static int add_cmp(void *ca_void, void *cb_void) { ASN1_OBJECT *a,*b; int i; + ADDED_OBJ *ca = (ADDED_OBJ *)ca_void; + ADDED_OBJ *cb = (ADDED_OBJ *)cb_void; i=ca->type-cb->type; if (i) return(i); @@ -174,13 +179,10 @@ static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) return(1); /* should not get here */ } -static IMPLEMENT_LHASH_HASH_FN(add_hash, ADDED_OBJ *) -static IMPLEMENT_LHASH_COMP_FN(add_cmp, ADDED_OBJ *) - static int init_added(void) { if (added != NULL) return(1); - added=lh_new(LHASH_HASH_FN(add_hash),LHASH_COMP_FN(add_cmp)); + added=lh_new(add_hash,add_cmp); return(added != NULL); } |