From 3fdc869c4565a77873fcf283329fd43c16ae75d9 Mon Sep 17 00:00:00 2001 From: jsing Date: Fri, 25 Apr 2014 13:55:25 +0000 Subject: [PATCH] The apps_{startup,shutdown} macro mess is now only used in openssl.c - reduce the macro to two functions and just call them instead. ok miod@ --- lib/libssl/src/apps/apps.h | 30 ---------------------- lib/libssl/src/apps/openssl.c | 48 ++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/lib/libssl/src/apps/apps.h b/lib/libssl/src/apps/apps.h index a79bdc94367..1f013e358bb 100644 --- a/lib/libssl/src/apps/apps.h +++ b/lib/libssl/src/apps/apps.h @@ -140,36 +140,6 @@ extern BIO *bio_err; #define zlib_cleanup() COMP_zlib_cleanup() #endif -#if !defined(OPENSSL_C) -# define apps_startup() \ - do_pipe_sig() -# define apps_shutdown() -#else -# ifndef OPENSSL_NO_ENGINE -# define apps_startup() \ - do { do_pipe_sig(); CRYPTO_malloc_init(); \ - ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \ - ENGINE_load_builtin_engines(); setup_ui_method(); } while(0) -# define apps_shutdown() \ - do { CONF_modules_unload(1); destroy_ui_method(); \ - OBJ_cleanup(); EVP_cleanup(); ENGINE_cleanup(); \ - CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \ - RAND_cleanup(); \ - ERR_free_strings(); zlib_cleanup();} while(0) -# else -# define apps_startup() \ - do { do_pipe_sig(); CRYPTO_malloc_init(); \ - ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \ - setup_ui_method(); } while(0) -# define apps_shutdown() \ - do { CONF_modules_unload(1); destroy_ui_method(); \ - OBJ_cleanup(); EVP_cleanup(); \ - CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \ - RAND_cleanup(); \ - ERR_free_strings(); zlib_cleanup(); } while(0) -# endif -#endif - typedef struct args_st { char **data; int count; diff --git a/lib/libssl/src/apps/openssl.c b/lib/libssl/src/apps/openssl.c index 5778191cb18..7070b4c896e 100644 --- a/lib/libssl/src/apps/openssl.c +++ b/lib/libssl/src/apps/openssl.c @@ -112,8 +112,6 @@ #include #include #include -#define OPENSSL_C /* tells apps.h to use complete - * apps_startup() */ #include "apps.h" #include #include @@ -130,13 +128,16 @@ #include "s_apps.h" #include +static void openssl_startup(void); +static void openssl_shutdown(void); + /* The LHASH callbacks ("hash" & "cmp") have been replaced by functions with the * base prototypes (we cast each variable inside the function to the required * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper * functions. */ -static LHASH_OF(FUNCTION) * prog_init(void); -static int do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]); +static LHASH_OF(FUNCTION) *prog_init(void); +static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]); static void list_pkey(BIO * out); static void list_cipher(BIO * out); static void list_md(BIO * out); @@ -195,6 +196,41 @@ err: } } +static void +openssl_startup(void) +{ + do_pipe_sig(); + + CRYPTO_malloc_init(); + ERR_load_crypto_strings(); + OpenSSL_add_all_algorithms(); + +#ifndef OPENSSL_NO_ENGINE + ENGINE_load_builtin_engines(); +#endif + + setup_ui_method(); +} + +static void +openssl_shutdown(void) +{ + CONF_modules_unload(1); + destroy_ui_method(); + OBJ_cleanup(); + EVP_cleanup(); + +#ifndef OPENSSL_NO_ENGINE + ENGINE_cleanup(); +#endif + + CRYPTO_cleanup_all_ex_data(); + ERR_remove_thread_state(NULL); + RAND_cleanup(); + ERR_free_strings(); + zlib_cleanup(); +} + int main(int argc, char **argv) { @@ -237,7 +273,7 @@ main(int argc, char **argv) CRYPTO_set_locking_callback(lock_dbg_cb); } - apps_startup(); + openssl_startup(); /* Lets load up our environment a little */ p = getenv("OPENSSL_CONF"); @@ -348,7 +384,7 @@ end: if (arg.data != NULL) free(arg.data); - apps_shutdown(); + openssl_shutdown(); CRYPTO_mem_leaks(bio_err); if (bio_err != NULL) { -- 2.20.1