From 58996b841ac1a19794d704b5622480adc165c434 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 26 Jun 2015 08:05:20 +0200 Subject: config/Global: allow calling config_get_string() with one argument default_value defaults to nullptr. --- src/config/ConfigGlobal.hxx | 2 +- src/config/ConfigPath.cxx | 2 +- src/fs/Config.cxx | 4 +--- src/input/plugins/CurlInputPlugin.cxx | 4 ++-- src/storage/Configured.cxx | 4 ++-- src/tag/TagConfig.cxx | 3 +-- test/read_conf.cxx | 2 +- 7 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/config/ConfigGlobal.hxx b/src/config/ConfigGlobal.hxx index 9e8687e82..b24b9aada 100644 --- a/src/config/ConfigGlobal.hxx +++ b/src/config/ConfigGlobal.hxx @@ -73,7 +73,7 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value); gcc_pure const char * -config_get_string(enum ConfigOption option, const char *default_value); +config_get_string(enum ConfigOption option, const char *default_value=nullptr); /** * Returns an optional configuration variable which contains an diff --git a/src/config/ConfigPath.cxx b/src/config/ConfigPath.cxx index fe42fdf60..c1e57b3ba 100644 --- a/src/config/ConfigPath.cxx +++ b/src/config/ConfigPath.cxx @@ -70,7 +70,7 @@ GetHome(Error &error) static AllocatedPath GetConfiguredHome(Error &error) { - const char *user = config_get_string(ConfigOption::USER, nullptr); + const char *user = config_get_string(ConfigOption::USER); return user != nullptr ? GetHome(user, error) : GetHome(error); diff --git a/src/fs/Config.cxx b/src/fs/Config.cxx index d40fa45cf..0b39a362f 100644 --- a/src/fs/Config.cxx +++ b/src/fs/Config.cxx @@ -26,9 +26,7 @@ bool ConfigureFS(Error &error) { #ifdef HAVE_FS_CHARSET - const char *charset = nullptr; - - charset = config_get_string(ConfigOption::FS_CHARSET, nullptr); + const char *charset = config_get_string(ConfigOption::FS_CHARSET); return charset == nullptr || SetFSCharset(charset, error); #else (void)error; diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx index ade8324ec..814fe7a32 100644 --- a/src/input/plugins/CurlInputPlugin.cxx +++ b/src/input/plugins/CurlInputPlugin.cxx @@ -566,9 +566,9 @@ input_curl_init(const ConfigBlock &block, Error &error) if (proxy == nullptr) { /* deprecated proxy configuration */ - proxy = config_get_string(ConfigOption::HTTP_PROXY_HOST, nullptr); + proxy = config_get_string(ConfigOption::HTTP_PROXY_HOST); proxy_port = config_get_positive(ConfigOption::HTTP_PROXY_PORT, 0); - proxy_user = config_get_string(ConfigOption::HTTP_PROXY_USER, nullptr); + proxy_user = config_get_string(ConfigOption::HTTP_PROXY_USER); proxy_password = config_get_string(ConfigOption::HTTP_PROXY_PASSWORD, ""); } diff --git a/src/storage/Configured.cxx b/src/storage/Configured.cxx index adb5c7dc5..d3a55eab8 100644 --- a/src/storage/Configured.cxx +++ b/src/storage/Configured.cxx @@ -68,7 +68,7 @@ CreateConfiguredStorage(EventLoop &event_loop, Error &error) { assert(!error.IsDefined()); - auto uri = config_get_string(ConfigOption::MUSIC_DIR, nullptr); + auto uri = config_get_string(ConfigOption::MUSIC_DIR); if (uri != nullptr && uri_has_scheme(uri)) return CreateConfiguredStorageUri(event_loop, uri, error); @@ -78,5 +78,5 @@ CreateConfiguredStorage(EventLoop &event_loop, Error &error) bool IsStorageConfigured() { - return config_get_string(ConfigOption::MUSIC_DIR, nullptr) != nullptr; + return config_get_string(ConfigOption::MUSIC_DIR) != nullptr; } diff --git a/src/tag/TagConfig.cxx b/src/tag/TagConfig.cxx index df40c2bc0..e4d40696d 100644 --- a/src/tag/TagConfig.cxx +++ b/src/tag/TagConfig.cxx @@ -35,8 +35,7 @@ void TagLoadConfig() { - const char *value = config_get_string(ConfigOption::METADATA_TO_USE, - nullptr); + const char *value = config_get_string(ConfigOption::METADATA_TO_USE); if (value == nullptr) return; diff --git a/test/read_conf.cxx b/test/read_conf.cxx index cb3cb207e..fdf93a40d 100644 --- a/test/read_conf.cxx +++ b/test/read_conf.cxx @@ -47,7 +47,7 @@ int main(int argc, char **argv) ConfigOption option = ParseConfigOptionName(name); const char *value = option != ConfigOption::MAX - ? config_get_string(option, nullptr) + ? config_get_string(option) : nullptr; int ret; if (value != NULL) { -- cgit v1.2.3