Move all the existing function pointer casts associated with LHASH's two
authorGeoff Thorpe <geoff@openssl.org>
Tue, 9 Jan 2001 00:24:38 +0000 (00:24 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Tue, 9 Jan 2001 00:24:38 +0000 (00:24 +0000)
"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).

CHANGES
crypto/conf/cnf_save.c
crypto/conf/conf_api.c
crypto/conf/conf_def.c
crypto/objects/o_names.c
crypto/objects/obj_dat.c
ssl/ssl_sess.c

diff --git a/CHANGES b/CHANGES
index 8cccebc..511156f 100644 (file)
--- 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
index efbb613..1439487 100644 (file)
@@ -59,7 +59,8 @@
 #include <stdio.h>
 #include <openssl/conf.h>
 
-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;
index bf84cec..a0596bf 100644 (file)
@@ -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);
        }
index 1d30f6f..59f9476 100644 (file)
@@ -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;
        }
 
index 87ea624..03d6539 100644 (file)
@@ -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);
index 9d47c8f..be72303 100644 (file)
@@ -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;
        }
index 830f1d9..9364612 100644 (file)
@@ -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);
        }