aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-06-19 09:02:14 +0200
committerMax Kellermann <max@duempel.org>2009-06-25 08:42:25 +0200
commit637c6a1850963638018e57b70ae3b807c3028a1d (patch)
tree57186f65dcb8e7f87f8f974efa954fc7d035783e
parent0cbc4012e85c275c64ad551ba4484ee5f505fe4c (diff)
downloadmpd-637c6a1850963638018e57b70ae3b807c3028a1d.tar.gz
mpd-637c6a1850963638018e57b70ae3b807c3028a1d.tar.xz
mpd-637c6a1850963638018e57b70ae3b807c3028a1d.zip
conf: log unused/unknown block parameters
-rw-r--r--NEWS1
-rw-r--r--src/conf.c29
-rw-r--r--src/conf.h6
-rw-r--r--src/main.c2
4 files changed, 38 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index f6c27f49f..e064f67cc 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ ver 0.16 (20??/??/??)
- removed support for legacy mixer configuration
* commands:
- added new "status" line with more precise "elapsed time"
+* log unused/unknown block parameters
ver 0.15 (2009/06/23)
diff --git a/src/conf.c b/src/conf.c
index ac08d7845..385dff4d4 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -188,6 +188,35 @@ void config_global_init(void)
{
}
+static void
+config_param_check(gpointer data, G_GNUC_UNUSED gpointer user_data)
+{
+ struct config_param *param = data;
+
+ if (!param->used)
+ /* this whole config_param was not queried at all -
+ the feature might be disabled at compile time?
+ Silently ignore it here. */
+ return;
+
+ for (unsigned i = 0; i < param->num_block_params; i++) {
+ struct block_param *bp = &param->block_params[i];
+
+ if (!bp->used)
+ g_warning("option '%s' on line %i was not recognized",
+ bp->name, bp->line);
+ }
+}
+
+void config_global_check(void)
+{
+ for (unsigned i = 0; i < G_N_ELEMENTS(config_entries); ++i) {
+ struct config_entry *entry = &config_entries[i];
+
+ g_slist_foreach(entry->params, config_param_check, NULL);
+ }
+}
+
void
config_add_block_param(struct config_param * param, const char *name,
const char *value, int line)
diff --git a/src/conf.h b/src/conf.h
index 1b3e074e1..8891879e7 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -100,6 +100,12 @@ struct config_param {
void config_global_init(void);
void config_global_finish(void);
+/**
+ * Call this function after all configuration has been evaluated. It
+ * checks for unused parameters, and logs warnings.
+ */
+void config_global_check(void);
+
void config_read_file(const char *file);
/* don't free the returned value
diff --git a/src/main.c b/src/main.c
index 5035a4836..cdf403266 100644
--- a/src/main.c
+++ b/src/main.c
@@ -322,6 +322,8 @@ int main(int argc, char *argv[])
state_file_init(config_get_path(CONF_STATE_FILE));
+ config_global_check();
+
/* run the main loop */
g_main_loop_run(main_loop);