You need to sign in or sign up before continuing.
Commit 5b192bea authored by Max Kellermann's avatar Max Kellermann

config/Global: remove ConfigBlock::SetUsed() call, let caller do that

This fixes an old bug which caused the "unused" warnings to be unreliable; only the first block in the list was marked as being "used", no matter if it was really used, and the rest was never marked as "used", suppressing all warnings for them.
parent ef38330d
...@@ -83,10 +83,7 @@ config_get_param(ConfigOption option) noexcept ...@@ -83,10 +83,7 @@ config_get_param(ConfigOption option) noexcept
const ConfigBlock * const ConfigBlock *
config_get_block(ConfigBlockOption option) noexcept config_get_block(ConfigBlockOption option) noexcept
{ {
const auto *block = config_data.blocks[unsigned(option)]; return config_data.blocks[unsigned(option)];
if (block != nullptr)
block->SetUsed();
return block;
} }
const ConfigBlock * const ConfigBlock *
......
...@@ -38,10 +38,11 @@ CreateConfiguredDatabase(EventLoop &main_event_loop, EventLoop &io_event_loop, ...@@ -38,10 +38,11 @@ CreateConfiguredDatabase(EventLoop &main_event_loop, EventLoop &io_event_loop,
throw FormatRuntimeError("Found both 'database' (line %d) and 'db_file' (line %d) setting", throw FormatRuntimeError("Found both 'database' (line %d) and 'db_file' (line %d) setting",
param->line, path->line); param->line, path->line);
if (param != nullptr) if (param != nullptr) {
param->SetUsed();
return DatabaseGlobalInit(main_event_loop, io_event_loop, return DatabaseGlobalInit(main_event_loop, io_event_loop,
listener, *param); listener, *param);
else if (path != nullptr) { } else if (path != nullptr) {
ConfigBlock block(path->line); ConfigBlock block(path->line);
block.AddBlockParam("path", path->value, path->line); block.AddBlockParam("path", path->value, path->line);
return DatabaseGlobalInit(main_event_loop, io_event_loop, return DatabaseGlobalInit(main_event_loop, io_event_loop,
......
...@@ -143,6 +143,9 @@ void decoder_plugin_init_all(void) ...@@ -143,6 +143,9 @@ void decoder_plugin_init_all(void)
/* the plugin is disabled in mpd.conf */ /* the plugin is disabled in mpd.conf */
continue; continue;
if (param != nullptr)
param->SetUsed();
if (plugin.Init(*param)) if (plugin.Init(*param))
decoder_plugins_enabled[i] = true; decoder_plugins_enabled[i] = true;
} }
......
...@@ -42,6 +42,8 @@ filter_chain_append_new(PreparedFilter &chain, const char *template_name) ...@@ -42,6 +42,8 @@ filter_chain_append_new(PreparedFilter &chain, const char *template_name)
throw FormatRuntimeError("Filter template not found: %s", throw FormatRuntimeError("Filter template not found: %s",
template_name); template_name);
cfg->SetUsed();
// Instantiate one of those filter plugins with the template name as a hint // Instantiate one of those filter plugins with the template name as a hint
auto f = filter_configured_new(*cfg); auto f = filter_configured_new(*cfg);
......
...@@ -53,6 +53,8 @@ input_stream_global_init(EventLoop &event_loop) ...@@ -53,6 +53,8 @@ input_stream_global_init(EventLoop &event_loop)
/* the plugin is disabled in mpd.conf */ /* the plugin is disabled in mpd.conf */
continue; continue;
block->SetUsed();
try { try {
if (plugin->init != nullptr) if (plugin->init != nullptr)
plugin->init(event_loop, *block); plugin->init(event_loop, *block);
......
...@@ -54,6 +54,8 @@ NeighborGlue::Init(EventLoop &loop, NeighborListener &listener) ...@@ -54,6 +54,8 @@ NeighborGlue::Init(EventLoop &loop, NeighborListener &listener)
{ {
for (const auto *block = config_get_block(ConfigBlockOption::NEIGHBORS); for (const auto *block = config_get_block(ConfigBlockOption::NEIGHBORS);
block != nullptr; block = block->next) { block != nullptr; block = block->next) {
block->SetUsed();
try { try {
explorers.emplace_front(CreateNeighborExplorer(loop, explorers.emplace_front(CreateNeighborExplorer(loop,
listener, listener,
......
...@@ -92,6 +92,7 @@ MultipleOutputs::Configure(EventLoop &event_loop, ...@@ -92,6 +92,7 @@ MultipleOutputs::Configure(EventLoop &event_loop,
{ {
for (const auto *param = config_get_block(ConfigBlockOption::AUDIO_OUTPUT); for (const auto *param = config_get_block(ConfigBlockOption::AUDIO_OUTPUT);
param != nullptr; param = param->next) { param != nullptr; param = param->next) {
param->SetUsed();
auto *output = LoadOutputControl(event_loop, auto *output = LoadOutputControl(event_loop,
replay_gain_config, replay_gain_config,
mixer_listener, mixer_listener,
......
...@@ -125,6 +125,7 @@ GetResamplerConfig(ConfigBlock &buffer) ...@@ -125,6 +125,7 @@ GetResamplerConfig(ConfigBlock &buffer)
throw FormatRuntimeError("Cannot use both 'resampler' (line %d) and 'samplerate_converter' (line %d)", throw FormatRuntimeError("Cannot use both 'resampler' (line %d) and 'samplerate_converter' (line %d)",
block->line, old_param->line); block->line, old_param->line);
block->SetUsed();
return block; return block;
} }
......
...@@ -90,6 +90,9 @@ playlist_list_global_init(void) ...@@ -90,6 +90,9 @@ playlist_list_global_init(void)
/* the plugin is disabled in mpd.conf */ /* the plugin is disabled in mpd.conf */
continue; continue;
if (param != nullptr)
param->SetUsed();
playlist_plugins_enabled[i] = playlist_plugins_enabled[i] =
playlist_plugin_init(playlist_plugins[i], *param); playlist_plugin_init(playlist_plugins[i], *param);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment