[PATCH weston 4/6] compositor: move code into load_configuration()

Pekka Paalanen ppaalanen at gmail.com
Tue Mar 24 06:56:18 PDT 2015


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Move the config file loading code from main() to its own function.

No functional changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 src/compositor.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 11730e2..2a0e66c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -5210,6 +5210,23 @@ weston_transform_to_string(uint32_t output_transform)
 	return "<illegal value>";
 }
 
+static int
+load_configuration(struct weston_config **config, int32_t noconfig)
+{
+	*config = NULL;
+
+	if (noconfig == 0)
+		*config = weston_config_parse("weston.ini");
+
+	if (*config) {
+		weston_log("Using config file '%s'\n",
+			   weston_config_get_full_path(*config));
+	} else {
+		weston_log("Starting with no config file.\n");
+	}
+
+	return 0;
+}
 
 int main(int argc, char *argv[])
 {
@@ -5235,7 +5252,7 @@ int main(int argc, char *argv[])
 	int32_t version = 0;
 	int32_t noconfig = 0;
 	int32_t numlock_on;
-	struct weston_config *config = NULL;
+	struct weston_config *config;
 	struct weston_config_section *section;
 	struct wl_client *primary_client;
 	struct wl_listener primary_client_destroyed;
@@ -5292,14 +5309,9 @@ int main(int argc, char *argv[])
 	if (!signals[0] || !signals[1] || !signals[2] || !signals[3])
 		goto out_signals;
 
-	if (noconfig == 0)
-		config = weston_config_parse("weston.ini");
-	if (config != NULL) {
-		weston_log("Using config file '%s'\n",
-			   weston_config_get_full_path(config));
-	} else {
-		weston_log("Starting with no config file.\n");
-	}
+	if (load_configuration(&config, noconfig) < 0)
+		goto out_signals;
+
 	section = weston_config_get_section(config, "core", NULL, NULL);
 
 	if (!backend) {
-- 
2.0.5



More information about the wayland-devel mailing list