diff options
author | slontis <shane.lontis@oracle.com> | 2023-03-20 14:48:33 +1000 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-04-24 14:39:19 +0200 |
commit | 09ff84bd2752cac649f57cfbf95b49dbce1c69ee (patch) | |
tree | 9a3dbf4aa9835f2be7d874cde743f6dfa1de6293 /demos/cms | |
parent | a80840c663e3409203b0235764e53d8624f74cb8 (diff) | |
download | openssl-09ff84bd2752cac649f57cfbf95b49dbce1c69ee.tar.gz |
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 <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20545)
Diffstat (limited to 'demos/cms')
-rw-r--r-- | demos/cms/cms_comp.c | 6 | ||||
-rw-r--r-- | demos/cms/cms_ddec.c | 6 | ||||
-rw-r--r-- | demos/cms/cms_dec.c | 7 | ||||
-rw-r--r-- | demos/cms/cms_denc.c | 8 | ||||
-rw-r--r-- | demos/cms/cms_enc.c | 8 | ||||
-rw-r--r-- | demos/cms/cms_sign.c | 8 | ||||
-rw-r--r-- | demos/cms/cms_sign2.c | 8 | ||||
-rw-r--r-- | demos/cms/cms_uncomp.c | 8 | ||||
-rw-r--r-- | demos/cms/cms_ver.c | 9 |
9 files changed, 27 insertions, 41 deletions
diff --git a/demos/cms/cms_comp.c b/demos/cms/cms_comp.c index ee1b5a38ce..3ccbfdddda 100644 --- a/demos/cms/cms_comp.c +++ b/demos/cms/cms_comp.c @@ -16,7 +16,7 @@ int main(int argc, char **argv) { BIO *in = NULL, *out = NULL; CMS_ContentInfo *cms = NULL; - int ret = 1; + int ret = EXIT_FAILURE; /* * On OpenSSL 1.0.0+ only: @@ -48,11 +48,11 @@ int main(int argc, char **argv) if (!SMIME_write_CMS(out, cms, in, flags)) goto err; - ret = 0; + ret = EXIT_SUCCESS; err: - if (ret) { + if (ret != EXIT_SUCCESS) { fprintf(stderr, "Error Compressing Data\n"); ERR_print_errors_fp(stderr); } diff --git a/demos/cms/cms_ddec.c b/demos/cms/cms_ddec.c index cb6c2694c6..285eba91df 100644 --- a/demos/cms/cms_ddec.c +++ b/demos/cms/cms_ddec.c @@ -21,7 +21,7 @@ int main(int argc, char **argv) X509 *rcert = NULL; EVP_PKEY *rkey = NULL; CMS_ContentInfo *cms = NULL; - int ret = 1; + int ret = EXIT_FAILURE; OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); @@ -68,11 +68,11 @@ int main(int argc, char **argv) if (!CMS_decrypt(cms, rkey, rcert, dcont, out, 0)) goto err; - ret = 0; + ret = EXIT_SUCCESS; err: - if (ret) { + if (ret != EXIT_SUCCESS) { fprintf(stderr, "Error Decrypting Data\n"); ERR_print_errors_fp(stderr); } diff --git a/demos/cms/cms_dec.c b/demos/cms/cms_dec.c index f33ef1eb78..436f0088d2 100644 --- a/demos/cms/cms_dec.c +++ b/demos/cms/cms_dec.c @@ -18,7 +18,7 @@ int main(int argc, char **argv) X509 *rcert = NULL; EVP_PKEY *rkey = NULL; CMS_ContentInfo *cms = NULL; - int ret = 1; + int ret = EXIT_FAILURE; OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); @@ -59,11 +59,10 @@ int main(int argc, char **argv) if (!CMS_decrypt(cms, rkey, rcert, NULL, out, 0)) goto err; - ret = 0; + ret = EXIT_SUCCESS; err: - - if (ret) { + if (ret != EXIT_SUCCESS) { fprintf(stderr, "Error Decrypting Data\n"); ERR_print_errors_fp(stderr); } diff --git a/demos/cms/cms_denc.c b/demos/cms/cms_denc.c index 4a2219dee3..4fbd72aae5 100644 --- a/demos/cms/cms_denc.c +++ b/demos/cms/cms_denc.c @@ -21,7 +21,7 @@ int main(int argc, char **argv) X509 *rcert = NULL; STACK_OF(X509) *recips = NULL; CMS_ContentInfo *cms = NULL; - int ret = 1; + int ret = EXIT_FAILURE; int flags = CMS_STREAM | CMS_DETACHED; @@ -77,11 +77,9 @@ int main(int argc, char **argv) if (!PEM_write_bio_CMS(out, cms)) goto err; - ret = 0; - + ret = EXIT_SUCCESS; err: - - if (ret) { + if (ret != EXIT_SUCCESS) { fprintf(stderr, "Error Encrypting Data\n"); ERR_print_errors_fp(stderr); } diff --git a/demos/cms/cms_enc.c b/demos/cms/cms_enc.c index ff5632a714..3af321521c 100644 --- a/demos/cms/cms_enc.c +++ b/demos/cms/cms_enc.c @@ -18,7 +18,7 @@ int main(int argc, char **argv) X509 *rcert = NULL; STACK_OF(X509) *recips = NULL; CMS_ContentInfo *cms = NULL; - int ret = 1; + int ret = EXIT_FAILURE; /* * On OpenSSL 1.0.0 and later only: @@ -73,11 +73,9 @@ int main(int argc, char **argv) if (!SMIME_write_CMS(out, cms, in, flags)) goto err; - ret = 0; - + ret = EXIT_SUCCESS; err: - - if (ret) { + if (ret != EXIT_SUCCESS) { fprintf(stderr, "Error Encrypting Data\n"); ERR_print_errors_fp(stderr); } diff --git a/demos/cms/cms_sign.c b/demos/cms/cms_sign.c index a52f5cec0f..8abc561941 100644 --- a/demos/cms/cms_sign.c +++ b/demos/cms/cms_sign.c @@ -18,7 +18,7 @@ int main(int argc, char **argv) X509 *scert = NULL; EVP_PKEY *skey = NULL; CMS_ContentInfo *cms = NULL; - int ret = 1; + int ret = EXIT_FAILURE; /* * For simple S/MIME signing use CMS_DETACHED. On OpenSSL 1.0.0 only: for @@ -69,11 +69,9 @@ int main(int argc, char **argv) if (!SMIME_write_CMS(out, cms, in, flags)) goto err; - ret = 0; - + ret = EXIT_SUCCESS; err: - - if (ret) { + if (ret != EXIT_SUCCESS) { fprintf(stderr, "Error Signing Data\n"); ERR_print_errors_fp(stderr); } diff --git a/demos/cms/cms_sign2.c b/demos/cms/cms_sign2.c index beda9779a3..72c7862593 100644 --- a/demos/cms/cms_sign2.c +++ b/demos/cms/cms_sign2.c @@ -18,7 +18,7 @@ int main(int argc, char **argv) X509 *scert = NULL, *scert2 = NULL; EVP_PKEY *skey = NULL, *skey2 = NULL; CMS_ContentInfo *cms = NULL; - int ret = 1; + int ret = EXIT_FAILURE; OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); @@ -77,11 +77,9 @@ int main(int argc, char **argv) if (!SMIME_write_CMS(out, cms, in, CMS_STREAM)) goto err; - ret = 0; - + ret = EXIT_SUCCESS; err: - - if (ret) { + if (ret != EXIT_SUCCESS) { fprintf(stderr, "Error Signing Data\n"); ERR_print_errors_fp(stderr); } diff --git a/demos/cms/cms_uncomp.c b/demos/cms/cms_uncomp.c index 35e68ebcc6..02106197b4 100644 --- a/demos/cms/cms_uncomp.c +++ b/demos/cms/cms_uncomp.c @@ -16,7 +16,7 @@ int main(int argc, char **argv) { BIO *in = NULL, *out = NULL; CMS_ContentInfo *cms = NULL; - int ret = 1; + int ret = EXIT_FAILURE; OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); @@ -42,11 +42,9 @@ int main(int argc, char **argv) if (!CMS_uncompress(cms, out, NULL, 0)) goto err; - ret = 0; - + ret = EXIT_SUCCESS; err: - - if (ret) { + if (ret != EXIT_SUCCESS) { fprintf(stderr, "Error Uncompressing Data\n"); ERR_print_errors_fp(stderr); } diff --git a/demos/cms/cms_ver.c b/demos/cms/cms_ver.c index 3c0a7aa19e..0b6c469bf4 100644 --- a/demos/cms/cms_ver.c +++ b/demos/cms/cms_ver.c @@ -18,8 +18,7 @@ int main(int argc, char **argv) X509_STORE *st = NULL; X509 *cacert = NULL; CMS_ContentInfo *cms = NULL; - - int ret = 1; + int ret = EXIT_FAILURE; OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); @@ -69,11 +68,9 @@ int main(int argc, char **argv) fprintf(stderr, "Verification Successful\n"); - ret = 0; - + ret = EXIT_SUCCESS; err: - - if (ret) { + if (ret != EXIT_SUCCESS) { fprintf(stderr, "Error Verifying Data\n"); ERR_print_errors_fp(stderr); } |