aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-09 21:32:12 +0200
committerMax Kellermann <max@duempel.org>2011-09-09 22:55:57 +0200
commit8e5f9c8160b5186c93c5d76789ffa88f3e5c2fde (patch)
treef71eb9f9c5dfa789f94eae4182490286b54788ad /src/log.c
parentc620fd42f4e8c36186c1e3c3523ac6bd1351f91d (diff)
downloadmpd-8e5f9c8160b5186c93c5d76789ffa88f3e5c2fde.tar.gz
mpd-8e5f9c8160b5186c93c5d76789ffa88f3e5c2fde.tar.xz
mpd-8e5f9c8160b5186c93c5d76789ffa88f3e5c2fde.zip
conf: turn config_get_path() into config_dup_path()
config_get_path() was somewhat flawed, because it pretended to be a function, when it really had a side effect. The second flaw was that it did not return the parser error, instead it aborted the whole process, which is bad style. The new function returns a duplicated (modified) string that must be freed by the caller, and returns a GError on failure.
Diffstat (limited to '')
-rw-r--r--src/log.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/log.c b/src/log.c
index 140b50a2e..86dd86eaa 100644
--- a/src/log.c
+++ b/src/log.c
@@ -271,10 +271,18 @@ log_init(bool verbose, bool use_stdout, GError **error_r)
return true;
#endif
} else {
- const char *path = config_get_path(CONF_LOG_FILE);
- assert(path != NULL);
-
- return log_init_file(path, param->line, error_r);
+ GError *error = NULL;
+ char *path = config_dup_path(CONF_LOG_FILE, &error);
+ if (path == NULL) {
+ assert(error != NULL);
+ g_propagate_error(error_r, error);
+ return false;
+ }
+
+ bool success = log_init_file(path, param->line,
+ error_r);
+ g_free(path);
+ return success;
}
}
}