From: Geoff Thorpe Date: Tue, 9 Jan 2001 00:24:38 +0000 (+0000) Subject: Move all the existing function pointer casts associated with LHASH's two X-Git-Tag: OpenSSL_0_9_6a-beta1~81^2~63 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3c914840520161d9ca121d38973a79b050916a8a;p=oweals%2Fopenssl.git Move all the existing function pointer casts associated with LHASH's two "doall" functions to using type-safe wrappers. As and where required, this can be replaced by redeclaring the underlying callbacks to use the underlying "void"-based prototypes (eg. if performance suffers from an extra level of function invocation). --- diff --git a/CHANGES b/CHANGES index 8cccebce28..511156f6c8 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,11 @@ Changes between 0.9.6 and 0.9.7 [xx XXX 2000] + *) Finish off removing the remaining LHASH function pointer casts. + There should no longer be any prototype-casting required when using + the LHASH abstraction, and any casts that remain are "bugs". + [Geoff Thorpe] + *) Change the Unix RAND_poll() variant to be able to poll several random devices and only read data for a small fragment of time to avoid hangs. Also separate out the Unix variant to it's own diff --git a/crypto/conf/cnf_save.c b/crypto/conf/cnf_save.c index efbb61373e..1439487526 100644 --- a/crypto/conf/cnf_save.c +++ b/crypto/conf/cnf_save.c @@ -59,7 +59,8 @@ #include #include -void print_conf(CONF_VALUE *cv); +static void print_conf(CONF_VALUE *cv); +static IMPLEMENT_LHASH_DOALL_FN(print_conf, CONF_VALUE *); main() { @@ -73,11 +74,11 @@ main() exit(1); } - lh_doall(conf,(LHASH_DOALL_FN_TYPE)print_conf); + lh_doall(conf,LHASH_DOALL_FN(print_conf)); } -void print_conf(CONF_VALUE *cv) +static void print_conf(CONF_VALUE *cv) { int i; CONF_VALUE *v; diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c index bf84cecc1e..a0596bfd4a 100644 --- a/crypto/conf/conf_api.c +++ b/crypto/conf/conf_api.c @@ -70,6 +70,8 @@ static void value_free_hash(CONF_VALUE *a, LHASH *conf); static void value_free_stack(CONF_VALUE *a,LHASH *conf); +static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE *, LHASH *) +static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE *, LHASH *) /* 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); */ @@ -198,13 +200,13 @@ void _CONF_free_data(CONF *conf) conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()' * works as expected */ - lh_doall_arg(conf->data, (LHASH_DOALL_ARG_FN_TYPE)value_free_hash, + lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash), conf->data); /* We now have only 'section' entries in the hash table. * Due to problems with */ - lh_doall_arg(conf->data, (LHASH_DOALL_ARG_FN_TYPE)value_free_stack, + lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_stack), conf->data); lh_free(conf->data); } diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index 1d30f6f771..59f9476dc6 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -710,9 +710,11 @@ static void dump_value(CONF_VALUE *a, BIO *out) BIO_printf(out, "[[%s]]\n", a->section); } +static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE *, BIO *) + static int def_dump(CONF *conf, BIO *out) { - lh_doall_arg(conf->data, (LHASH_DOALL_ARG_FN_TYPE)dump_value, out); + lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out); return 1; } diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index 87ea624f2e..03d65397b8 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -248,6 +248,8 @@ static void do_all_fn(const OBJ_NAME *name,struct doall *d) d->fn(name,d->arg); } +static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME *, struct doall *) + void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg) { struct doall d; @@ -256,7 +258,7 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg) d.fn=fn; d.arg=arg; - lh_doall_arg(names_lh,(LHASH_DOALL_ARG_FN_TYPE)do_all_fn,&d); + lh_doall_arg(names_lh,LHASH_DOALL_ARG_FN(do_all_fn),&d); } struct doall_sorted @@ -316,6 +318,8 @@ static void names_lh_free(OBJ_NAME *onp) } } +static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME *) + static void name_funcs_free(NAME_FUNCS *ptr) { OPENSSL_free(ptr); @@ -331,7 +335,7 @@ void OBJ_NAME_cleanup(int type) down_load=names_lh->down_load; names_lh->down_load=0; - lh_doall(names_lh,(LHASH_DOALL_FN_TYPE)names_lh_free); + lh_doall(names_lh,LHASH_DOALL_FN(names_lh_free)); if (type < 0) { lh_free(names_lh); diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index 9d47c8fb8d..be72303ebd 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -204,13 +204,17 @@ static void cleanup3(ADDED_OBJ *a) OPENSSL_free(a); } +static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ *) +static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ *) +static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ *) + void OBJ_cleanup(void) { if (added == NULL) return; added->down_load=0; - lh_doall(added,(LHASH_DOALL_FN_TYPE)cleanup1); /* zero counters */ - lh_doall(added,(LHASH_DOALL_FN_TYPE)cleanup2); /* set counters */ - lh_doall(added,(LHASH_DOALL_FN_TYPE)cleanup3); /* free objects */ + lh_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */ + lh_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */ + lh_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */ lh_free(added); added=NULL; } diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 830f1d9b0f..9364612e40 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -594,6 +594,8 @@ static void timeout(SSL_SESSION *s, TIMEOUT_PARAM *p) } } +static IMPLEMENT_LHASH_DOALL_ARG_FN(timeout, SSL_SESSION *, TIMEOUT_PARAM *) + void SSL_CTX_flush_sessions(SSL_CTX *s, long t) { unsigned long i; @@ -606,7 +608,7 @@ void SSL_CTX_flush_sessions(SSL_CTX *s, long t) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); i=tp.cache->down_load; tp.cache->down_load=0; - lh_doall_arg(tp.cache, (LHASH_DOALL_ARG_FN_TYPE)timeout, &tp); + lh_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout), &tp); tp.cache->down_load=i; CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); }