From 9c3bcfa027cb32421ed20ab77553860b922b82fc Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Fri, 15 May 2015 13:50:38 -0400 Subject: Standardize handling of #ifdef'd options. Here are the "rules" for handling flags that depend on #ifdef: - Do not ifdef the enum. Only ifdef the OPTIONS table. All ifdef'd entries appear at the end; by convention "engine" is last. This ensures that at run-time, the flag will never be recognized/allowed. The next two bullets entries are for silencing compiler warnings: - In the while/switch parsing statement, use #ifdef for the body to disable it; leave the "case OPT_xxx:" and "break" statements outside the ifdef/ifndef. See ciphers.c for example. - If there are multiple options controlled by a single guard, OPT_FOO, OPT_BAR, etc., put a an #ifdef around the set, and then do "#else" and a series of case labels and a break. See OPENSSL_NO_AES in cms.c for example. Reviewed-by: Matt Caswell --- apps/dsa.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'apps/dsa.c') diff --git a/apps/dsa.c b/apps/dsa.c index f02f29399a..f61e151f88 100644 --- a/apps/dsa.c +++ b/apps/dsa.c @@ -82,14 +82,8 @@ OPTIONS dsa_options[] = { {"help", OPT_HELP, '-', "Display this summary"}, {"inform", OPT_INFORM, 'F', "Input format, DER PEM PVK"}, {"outform", OPT_OUTFORM, 'F', "Output format, DER PEM PVK"}, -# ifndef OPENSSL_NO_ENGINE - {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, -# endif {"in", OPT_IN, '<', "Input file"}, {"out", OPT_OUT, '>', "Output file"}, - {"pvk-strong", OPT_PVK_STRONG, '-'}, - {"pvk-weak", OPT_PVK_WEAK, '-'}, - {"pvk-none", OPT_PVK_NONE, '-'}, {"noout", OPT_NOOUT, '-', "Don't print key out"}, {"text", OPT_TEXT, '-', "Print the key in text"}, {"modulus", OPT_MODULUS, '-', "Print the DSA public value"}, @@ -98,6 +92,14 @@ OPTIONS dsa_options[] = { {"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"", OPT_CIPHER, '-', "Any supported cipher"}, +# ifndef OPENSSL_NO_RC4 + {"pvk-strong", OPT_PVK_STRONG, '-'}, + {"pvk-weak", OPT_PVK_WEAK, '-'}, + {"pvk-none", OPT_PVK_NONE, '-'}, +# endif +# ifndef OPENSSL_NO_ENGINE + {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, +# endif {NULL} }; @@ -118,11 +120,6 @@ int dsa_main(int argc, char **argv) switch (o) { case OPT_EOF: case OPT_ERR: -#ifdef OPENSSL_NO_RC4 - case OPT_PVK_STRONG: - case OPT_PVK_WEAK: - case OPT_PVK_NONE: -#endif opthelp: ret = 0; BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); @@ -166,6 +163,11 @@ int dsa_main(int argc, char **argv) case OPT_PVK_NONE: pvk_encr = 0; break; +#else + case OPT_PVK_STRONG: + case OPT_PVK_WEAK: + case OPT_PVK_NONE: + break; #endif case OPT_NOOUT: noout = 1; -- cgit v1.2.3