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.
This commit is contained in:
parent
ef38330d74
commit
5b192beaa5
|
@ -83,10 +83,7 @@ config_get_param(ConfigOption option) noexcept
|
|||
const ConfigBlock *
|
||||
config_get_block(ConfigBlockOption option) noexcept
|
||||
{
|
||||
const auto *block = config_data.blocks[unsigned(option)];
|
||||
if (block != nullptr)
|
||||
block->SetUsed();
|
||||
return block;
|
||||
return config_data.blocks[unsigned(option)];
|
||||
}
|
||||
|
||||
const ConfigBlock *
|
||||
|
|
|
@ -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",
|
||||
param->line, path->line);
|
||||
|
||||
if (param != nullptr)
|
||||
if (param != nullptr) {
|
||||
param->SetUsed();
|
||||
return DatabaseGlobalInit(main_event_loop, io_event_loop,
|
||||
listener, *param);
|
||||
else if (path != nullptr) {
|
||||
} else if (path != nullptr) {
|
||||
ConfigBlock block(path->line);
|
||||
block.AddBlockParam("path", path->value, path->line);
|
||||
return DatabaseGlobalInit(main_event_loop, io_event_loop,
|
||||
|
|
|
@ -143,6 +143,9 @@ void decoder_plugin_init_all(void)
|
|||
/* the plugin is disabled in mpd.conf */
|
||||
continue;
|
||||
|
||||
if (param != nullptr)
|
||||
param->SetUsed();
|
||||
|
||||
if (plugin.Init(*param))
|
||||
decoder_plugins_enabled[i] = true;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@ filter_chain_append_new(PreparedFilter &chain, const char *template_name)
|
|||
throw FormatRuntimeError("Filter template not found: %s",
|
||||
template_name);
|
||||
|
||||
cfg->SetUsed();
|
||||
|
||||
// Instantiate one of those filter plugins with the template name as a hint
|
||||
auto f = filter_configured_new(*cfg);
|
||||
|
||||
|
|
|
@ -53,6 +53,8 @@ input_stream_global_init(EventLoop &event_loop)
|
|||
/* the plugin is disabled in mpd.conf */
|
||||
continue;
|
||||
|
||||
block->SetUsed();
|
||||
|
||||
try {
|
||||
if (plugin->init != nullptr)
|
||||
plugin->init(event_loop, *block);
|
||||
|
|
|
@ -54,6 +54,8 @@ NeighborGlue::Init(EventLoop &loop, NeighborListener &listener)
|
|||
{
|
||||
for (const auto *block = config_get_block(ConfigBlockOption::NEIGHBORS);
|
||||
block != nullptr; block = block->next) {
|
||||
block->SetUsed();
|
||||
|
||||
try {
|
||||
explorers.emplace_front(CreateNeighborExplorer(loop,
|
||||
listener,
|
||||
|
|
|
@ -92,6 +92,7 @@ MultipleOutputs::Configure(EventLoop &event_loop,
|
|||
{
|
||||
for (const auto *param = config_get_block(ConfigBlockOption::AUDIO_OUTPUT);
|
||||
param != nullptr; param = param->next) {
|
||||
param->SetUsed();
|
||||
auto *output = LoadOutputControl(event_loop,
|
||||
replay_gain_config,
|
||||
mixer_listener,
|
||||
|
|
|
@ -125,6 +125,7 @@ GetResamplerConfig(ConfigBlock &buffer)
|
|||
throw FormatRuntimeError("Cannot use both 'resampler' (line %d) and 'samplerate_converter' (line %d)",
|
||||
block->line, old_param->line);
|
||||
|
||||
block->SetUsed();
|
||||
return block;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,9 @@ playlist_list_global_init(void)
|
|||
/* the plugin is disabled in mpd.conf */
|
||||
continue;
|
||||
|
||||
if (param != nullptr)
|
||||
param->SetUsed();
|
||||
|
||||
playlist_plugins_enabled[i] =
|
||||
playlist_plugin_init(playlist_plugins[i], *param);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue