From 25a53a649a6d700584dd9f8f1c06fb0606fb69b9 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Thu, 14 Feb 2019 13:27:43 +0200 Subject: [PATCH] MXS-2304 Remove config_get_param() Replaced with other functions. Also removed password deprecation check. --- server/core/config.cc | 53 +++++---------------------------- server/core/internal/config.hh | 9 ------ server/core/test/test_server.cc | 13 ++++---- 3 files changed, 14 insertions(+), 61 deletions(-) diff --git a/server/core/config.cc b/server/core/config.cc index 9f5b138e4..45580b503 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -1709,34 +1709,6 @@ static bool process_config_context(CONFIG_CONTEXT* context) return error_count == 0; } -void do_passwd_deprecation(CONFIG_CONTEXT* obj) -{ - if (auto p = config_get_param(obj->parameters, "passwd")) - { - if (obj->parameters->contains(CN_PASSWORD)) - { - MXS_WARNING("Both 'password' and 'passwd' specified. Using value of '%s'.", CN_PASSWORD); - } - - MXS_WARNING("The parameter 'passwd' is deprecated: use '%s' instead", CN_PASSWORD); - config_replace_param(obj, CN_PASSWORD, p->value); - } -} - -MXS_CONFIG_PARAMETER* config_get_param(MXS_CONFIG_PARAMETER* params, const char* name) -{ - while (params) - { - if (!strcmp(params->name, name)) - { - return params; - } - - params = params->next; - } - return NULL; -} - bool MXS_CONFIG_PARAMETER::get_bool(const std::string& key) const { string param_value = get_string(key); @@ -1963,25 +1935,18 @@ bool config_add_param(CONFIG_CONTEXT* obj, const char* key, const char* value) bool config_append_param(CONFIG_CONTEXT* obj, const char* key, const char* value) { - MXS_CONFIG_PARAMETER* param = config_get_param(obj->parameters, key); - mxb_assert(param); - int paramlen = strlen(param->value) + strlen(value) + 2; - char tmp[paramlen]; + mxb_assert(obj->parameters->contains(key)); + auto old_val = obj->parameters->get_string(key); + string new_val = old_val + "," + value; + char* new_val_z = config_clean_string_list(new_val.c_str()); + bool rval = false; - - strcpy(tmp, param->value); - strcat(tmp, ","); - strcat(tmp, value); - - char* new_value = config_clean_string_list(tmp); - - if (new_value) + if (new_val_z) { - MXS_FREE(param->value); - param->value = new_value; + MXS_CONFIG_PARAMETER::set(&obj->parameters, key, new_val_z); + MXS_FREE(new_val_z); rval = true; } - return rval; } @@ -3170,8 +3135,6 @@ static bool check_config_objects(CONFIG_CONTEXT* context) } } - do_passwd_deprecation(obj); - for (const auto& a : to_be_removed) { config_remove_param(obj, a.c_str()); diff --git a/server/core/internal/config.hh b/server/core/internal/config.hh index dfb2eff80..69d4fed77 100644 --- a/server/core/internal/config.hh +++ b/server/core/internal/config.hh @@ -253,12 +253,3 @@ void dump_param_list(int file, * @return True if the parameter can be modified at runtime */ bool config_can_modify_at_runtime(const char* name); - -/** - * @brief Get a configuration parameter - * - * @param params List of parameters - * @param name Name of parameter to get - * @return The parameter or NULL if the parameter was not found - */ -MXS_CONFIG_PARAMETER* config_get_param(MXS_CONFIG_PARAMETER* params, const char* name); diff --git a/server/core/test/test_server.cc b/server/core/test/test_server.cc index 3dbdf2d9c..f09431c85 100644 --- a/server/core/test/test_server.cc +++ b/server/core/test/test_server.cc @@ -112,14 +112,13 @@ bool test_load_config(const char* input, Server* server) config_add_defaults(obj, config_server_params); TEST(strcmp(obj->object, server->name()) == 0, "Server names differ"); - TEST(strcmp(server->address, config_get_param(param, "address")->value) == 0, - "Server addresses differ"); - TEST(server->protocol() == config_get_param(param, "protocol")->value, - "Server protocols differ"); - TEST(server->get_authenticator() == config_get_param(param, "authenticator")->value, + TEST(param->get_string("address") == server->address, "Server addresses differ"); + TEST(param->get_string("protocol") == server->protocol(), "Server protocols differ"); + TEST(param->get_string("authenticator") == server->get_authenticator(), "Server authenticators differ"); - TEST(server->port == atoi(config_get_param(param, "port")->value), "Server ports differ"); - TEST(Server::server_alloc(obj->object, obj->parameters), "Failed to create server from loaded config"); + TEST(param->get_integer("port") == server->port, "Server ports differ"); + TEST(Server::server_alloc(obj->object, obj->parameters), + "Failed to create server from loaded config"); duplicate_context_finish(&dcontext); config_context_free(obj); }