diff options
author | yangyangtiantianlonglong <yangtianlong1224@163.com> | 2022-02-16 23:33:17 +0800 |
---|---|---|
committer | Dr. Matthias St. Pierre <matthias.st.pierre@ncp-e.com> | 2022-02-20 12:58:18 +0100 |
commit | 18e046c8a2e562cf947aa2b5b4cce31bb0ff75a1 (patch) | |
tree | 6fd283a9c9e2194690d4e1e8e20af6a69dbed14b /doc | |
parent | 6ff03e39189b4b1767157d1e1035365036f4f907 (diff) |
doc: Refactored the example in crypto.pod
Added return value and error code in the sample
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17721)
(cherry picked from commit 4a4f446008938775c2bea3001c4c8e7a674992ad)
Diffstat (limited to 'doc')
-rw-r--r-- | doc/man7/crypto.pod | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/doc/man7/crypto.pod b/doc/man7/crypto.pod index 2b09ad8903..a0cdca4fb3 100644 --- a/doc/man7/crypto.pod +++ b/doc/man7/crypto.pod @@ -380,6 +380,7 @@ encryption/decryption, signatures, message authentication codes, etc. #include <stdio.h> #include <openssl/evp.h> #include <openssl/bio.h> + #include <openssl/err.h> int main(void) { @@ -390,6 +391,7 @@ encryption/decryption, signatures, message authentication codes, etc. }; unsigned int len = 0; unsigned char *outdigest = NULL; + int ret = 1; /* Create a context for the digest operation */ ctx = EVP_MD_CTX_new(); @@ -430,11 +432,16 @@ encryption/decryption, signatures, message authentication codes, etc. /* Print out the digest result */ BIO_dump_fp(stdout, outdigest, len); + ret = 0; + err: /* Clean up all the resources we allocated */ OPENSSL_free(outdigest); EVP_MD_free(sha256); EVP_MD_CTX_free(ctx); + if (ret != 0) + ERR_print_errors_fp(stderr); + return ret; } =head1 CONFIGURATION |