aboutsummaryrefslogtreecommitdiffstats
path: root/src/conf.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-06-19 07:02:14 +0200
committerMax Kellermann <max@duempel.org>2009-06-25 08:41:09 +0200
commit8074b826530231755d7c1374eaa94802d7d24156 (patch)
tree0093a68c48fd6545e84039bdaa5ae14a241083e0 /src/conf.c
parent5d583c9b2d21cf449c4b65f2306adf69d6739437 (diff)
downloadmpd-8074b826530231755d7c1374eaa94802d7d24156.tar.gz
mpd-8074b826530231755d7c1374eaa94802d7d24156.tar.xz
mpd-8074b826530231755d7c1374eaa94802d7d24156.zip
conf: detect duplicate parameters in config_add_block_param()
Moved the check from config_get_block_param(). Detect the duplicate parameter when it's added, not when it's queried.
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/conf.c b/src/conf.c
index 0c50d4c8a..20cf4be8e 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -193,6 +193,12 @@ config_add_block_param(struct config_param * param, const char *name,
{
struct block_param *bp;
+ bp = config_get_block_param(param, name);
+ if (bp != NULL)
+ g_error("\"%s\" first defined on line %i, and "
+ "redefined on line %i\n", name,
+ bp->line, line);
+
param->num_block_params++;
param->block_params = g_realloc(param->block_params,
@@ -406,23 +412,17 @@ config_get_positive(const char *name, unsigned default_value)
struct block_param *
config_get_block_param(const struct config_param * param, const char *name)
{
- struct block_param *ret = NULL;
-
if (param == NULL)
return NULL;
for (unsigned i = 0; i < param->num_block_params; i++) {
if (0 == strcmp(name, param->block_params[i].name)) {
- if (ret) {
- g_warning("\"%s\" first defined on line %i, and "
- "redefined on line %i\n", name,
- ret->line, param->block_params[i].line);
- }
- ret = param->block_params + i;
+ struct block_param *bp = &param->block_params[i];
+ return bp;
}
}
- return ret;
+ return NULL;
}
bool config_get_bool(const char *name, bool default_value)