From 51ba9ebd09bfa3569fee935ef7063394820cd333 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Fri, 16 Aug 2019 18:05:08 -0400 Subject: [PATCH] Avoid ?: construct in XXXerr calls It either makes the flow of control simpler and more obvious, or it is just a "cleanup" so that the editing scripts will find and fixup things. Reviewed-by: Dmitry Belyavskiy Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/9441) --- crypto/evp/evp_lib.c | 16 ++++++++-------- crypto/evp/evp_locl.h | 4 ++-- crypto/rand/drbg_lib.c | 7 ++++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index e48c63037e..4ec880fd13 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -60,10 +60,10 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) } } else ret = -1; - if (ret <= 0) - EVPerr(EVP_F_EVP_CIPHER_PARAM_TO_ASN1, ret == -2 ? - ASN1_R_UNSUPPORTED_CIPHER : - EVP_R_CIPHER_PARAMETER_ERROR); + if (ret == -2) + EVPerr(EVP_F_EVP_CIPHER_PARAM_TO_ASN1, ASN1_R_UNSUPPORTED_CIPHER); + else if (ret <= 0) + EVPerr(EVP_F_EVP_CIPHER_PARAM_TO_ASN1, EVP_R_CIPHER_PARAMETER_ERROR); if (ret < -1) ret = -1; return ret; @@ -106,10 +106,10 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type) } } else ret = -1; - if (ret <= 0) - EVPerr(EVP_F_EVP_CIPHER_ASN1_TO_PARAM, ret == -2 ? - EVP_R_UNSUPPORTED_CIPHER : - EVP_R_CIPHER_PARAMETER_ERROR); + if (ret == -2) + EVPerr(EVP_F_EVP_CIPHER_ASN1_TO_PARAM, EVP_R_UNSUPPORTED_CIPHER); + else if (ret <= 0) + EVPerr(EVP_F_EVP_CIPHER_ASN1_TO_PARAM, EVP_R_CIPHER_PARAMETER_ERROR); if (ret < -1) ret = -1; return ret; diff --git a/crypto/evp/evp_locl.h b/crypto/evp/evp_locl.h index ebfa3acd08..3437e04b67 100644 --- a/crypto/evp/evp_locl.h +++ b/crypto/evp/evp_locl.h @@ -233,7 +233,7 @@ OSSL_PARAM *evp_pkey_to_param(EVP_PKEY *pkey, size_t *sz); size_t pksize = (size_t)EVP_PKEY_size(ctx->pkey); \ \ if (pksize == 0) { \ - EVPerr(err, EVP_R_INVALID_KEY); /*ckerr_ignore*/ \ + ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_KEY); /*ckerr_ignore*/ \ return 0; \ } \ if (arg == NULL) { \ @@ -241,7 +241,7 @@ OSSL_PARAM *evp_pkey_to_param(EVP_PKEY *pkey, size_t *sz); return 1; \ } \ if (*arglen < pksize) { \ - EVPerr(err, EVP_R_BUFFER_TOO_SMALL); /*ckerr_ignore*/ \ + ERR_raise(ERR_LIB_EVP, EVP_R_BUFFER_TOO_SMALL); /*ckerr_ignore*/ \ return 0; \ } \ } diff --git a/crypto/rand/drbg_lib.c b/crypto/rand/drbg_lib.c index c24222188f..bce2f74e9a 100644 --- a/crypto/rand/drbg_lib.c +++ b/crypto/rand/drbg_lib.c @@ -541,9 +541,10 @@ int RAND_DRBG_instantiate(RAND_DRBG *drbg, } if (drbg->state != DRBG_UNINITIALISED) { - RANDerr(RAND_F_RAND_DRBG_INSTANTIATE, - drbg->state == DRBG_ERROR ? RAND_R_IN_ERROR_STATE - : RAND_R_ALREADY_INSTANTIATED); + if (drbg->state == DRBG_ERROR) + RANDerr(RAND_F_RAND_DRBG_INSTANTIATE, RAND_R_IN_ERROR_STATE); + else + RANDerr(RAND_F_RAND_DRBG_INSTANTIATE, RAND_R_ALREADY_INSTANTIATED); goto end; } -- 2.25.1