From 09ff84bd2752cac649f57cfbf95b49dbce1c69ee Mon Sep 17 00:00:00 2001 From: slontis Date: Mon, 20 Mar 2023 14:48:33 +1000 Subject: Fixup demo exit status magic numbers The demo code is quite often block copied for new demos, so this PR changes demos to use EXIT_SUCCESS & EXIT_FAILURE instead of using 0 and 1. Internal functions use the normal notation of 0 = error, 1 = success, but the value returned by main() must use EXIT_SUCCESS and EXIT_FAILURE. Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/20545) --- demos/encode/ec_encode.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'demos/encode/ec_encode.c') diff --git a/demos/encode/ec_encode.c b/demos/encode/ec_encode.c index 8c296fbad8..a5fe2213df 100644 --- a/demos/encode/ec_encode.c +++ b/demos/encode/ec_encode.c @@ -28,7 +28,7 @@ static const char *propq = NULL; */ static EVP_PKEY *load_key(OSSL_LIB_CTX *libctx, FILE *f, const char *passphrase) { - int rv = 0; + int ret = 0; EVP_PKEY *pkey = NULL; OSSL_DECODER_CTX *dctx = NULL; int selection = 0; @@ -75,7 +75,7 @@ static EVP_PKEY *load_key(OSSL_LIB_CTX *libctx, FILE *f, const char *passphrase) goto cleanup; } - rv = 1; + ret = 1; cleanup: OSSL_DECODER_CTX_free(dctx); @@ -84,7 +84,7 @@ cleanup: * might fail subsequently, so ensure it's properly freed * in this case. */ - if (rv == 0) { + if (ret == 0) { EVP_PKEY_free(pkey); pkey = NULL; } @@ -100,7 +100,7 @@ cleanup: */ static int store_key(EVP_PKEY *pkey, FILE *f, const char *passphrase) { - int rv = 0; + int ret = 0; int selection; OSSL_ENCODER_CTX *ectx = NULL; @@ -165,15 +165,15 @@ static int store_key(EVP_PKEY *pkey, FILE *f, const char *passphrase) goto cleanup; } - rv = 1; + ret = 1; cleanup: OSSL_ENCODER_CTX_free(ectx); - return rv; + return ret; } int main(int argc, char **argv) { - int rv = 1; + int ret = EXIT_FAILURE; OSSL_LIB_CTX *libctx = NULL; EVP_PKEY *pkey = NULL; const char *passphrase_in = NULL, *passphrase_out = NULL; @@ -197,9 +197,9 @@ int main(int argc, char **argv) goto cleanup; } - rv = 0; + ret = EXIT_SUCCESS; cleanup: EVP_PKEY_free(pkey); OSSL_LIB_CTX_free(libctx); - return rv; + return ret; } -- cgit v1.2.1