diff options
author | Max Kellermann <max@duempel.org> | 2011-09-09 21:16:46 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-09-09 21:36:41 +0200 |
commit | bc0fec0afe8e541dd2d7df2ddbe04b13f6a93678 (patch) | |
tree | 47b4c938ced03b5707a3deae07f2cb838a6a6fbb /src/conf.c | |
parent | e3eca82cc3b3c3fd0b8557c1ec9ae99d1532b054 (diff) | |
download | mpd-bc0fec0afe8e541dd2d7df2ddbe04b13f6a93678.tar.gz mpd-bc0fec0afe8e541dd2d7df2ddbe04b13f6a93678.tar.xz mpd-bc0fec0afe8e541dd2d7df2ddbe04b13f6a93678.zip |
conf: move duplicate check to _read_name_value()
config_add_block_param() cannot fail, which makes it easier to use.
Diffstat (limited to '')
-rw-r--r-- | src/conf.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/conf.c b/src/conf.c index ee5aaceb3..47a3bae9c 100644 --- a/src/conf.c +++ b/src/conf.c @@ -223,20 +223,13 @@ void config_global_check(void) } } -bool +void config_add_block_param(struct config_param * param, const char *name, - const char *value, int line, GError **error_r) + const char *value, int line) { struct block_param *bp; - bp = config_get_block_param(param, name); - if (bp != NULL) { - g_set_error(error_r, config_quark(), 0, - "\"%s\" first defined on line %i, and " - "redefined on line %i\n", name, - bp->line, line); - return false; - } + assert(config_get_block_param(param, name) == NULL); param->num_block_params++; @@ -250,8 +243,6 @@ config_add_block_param(struct config_param * param, const char *name, bp->value = g_strdup(value); bp->line = line; bp->used = false; - - return true; } static bool @@ -283,8 +274,16 @@ config_read_name_value(struct config_param *param, char *input, unsigned line, return false; } - return config_add_block_param(param, name, value, line, - error_r); + const struct block_param *bp = config_get_block_param(param, name); + if (bp != NULL) { + g_set_error(error_r, config_quark(), 0, + "\"%s\" is duplicate, first defined on line %i", + name, bp->line); + return false; + } + + config_add_block_param(param, name, value, line); + return true; } static struct config_param * |