From a150f8e1fcc38752fef4d7c75d765d8efc7d46d6 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 4 Nov 2020 16:14:00 +0100 Subject: CRYPTO: refactor ERR_raise()+ERR_add_error_data() to ERR_raise_data() This is not done absolutely everywhere, as there are places where the use of ERR_add_error_data() is quite complex, but at least the simple cases are done. Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/13318) --- crypto/engine/eng_cnf.c | 12 ++++++------ crypto/engine/eng_fat.c | 5 ++--- crypto/engine/eng_list.c | 3 +-- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'crypto/engine') diff --git a/crypto/engine/eng_cnf.c b/crypto/engine/eng_cnf.c index 4a14400a04..14744bb7f5 100644 --- a/crypto/engine/eng_cnf.c +++ b/crypto/engine/eng_cnf.c @@ -133,12 +133,12 @@ static int int_engine_configure(const char *name, const char *value, const CONF ret = 1; err: if (ret != 1) { - ERR_raise(ERR_LIB_ENGINE, - ENGINE_R_ENGINE_CONFIGURATION_ERROR); - if (ecmd) - ERR_add_error_data(6, "section=", ecmd->section, - ", name=", ecmd->name, - ", value=", ecmd->value); + if (ecmd == NULL) + ERR_raise(ERR_LIB_ENGINE, ENGINE_R_ENGINE_CONFIGURATION_ERROR); + else + ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_ENGINE_CONFIGURATION_ERROR, + "section=%s, name=%s, value=%s", + ecmd->section, ecmd->name, ecmd->value); } ENGINE_free(e); return ret; diff --git a/crypto/engine/eng_fat.c b/crypto/engine/eng_fat.c index 7b971678fd..78537057b7 100644 --- a/crypto/engine/eng_fat.c +++ b/crypto/engine/eng_fat.c @@ -85,9 +85,8 @@ int ENGINE_set_default_string(ENGINE *e, const char *def_list) { unsigned int flags = 0; if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) { - ERR_raise(ERR_LIB_ENGINE, - ENGINE_R_INVALID_STRING); - ERR_add_error_data(2, "str=", def_list); + ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_INVALID_STRING, + "str=%s", def_list); return 0; } return ENGINE_set_default(e, flags); diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index 3008384d3f..de3475fe22 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -335,8 +335,7 @@ ENGINE *ENGINE_by_id(const char *id) } notfound: ENGINE_free(iterator); - ERR_raise(ERR_LIB_ENGINE, ENGINE_R_NO_SUCH_ENGINE); - ERR_add_error_data(2, "id=", id); + ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_NO_SUCH_ENGINE, "id=%s", id); return NULL; /* EEK! Experimental code ends */ } -- cgit v1.2.3