[PATCH weston v4 08/14] compositor-wayland: replace and remove new_config in load_wayland_backend_config

Benoit Gschwind gschwind at gnu-log.net
Tue May 10 20:47:51 UTC 2016


Remove the unseless intermediate variable new_config in the function
load_wayland_backend_config, replacing it by the existing variable
out_config.

Signed-off-by: Benoit Gschwind <gschwind at gnu-log.net>
---
 src/main.c | 44 ++++++++++++++++++++------------------------
 1 file changed, 20 insertions(+), 24 deletions(-)

diff --git a/src/main.c b/src/main.c
index 24321e7..231f1b9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1123,7 +1123,6 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc,
 			    char *argv[], struct weston_config *wc,
 			    struct weston_wayland_backend_config *out_config)
 {
-	struct weston_wayland_backend_config new_config = {{ 0, }};
 	struct weston_config_section *section;
 	struct weston_wayland_backend_output_config *oc;
 	int count, width, height, scale;
@@ -1134,43 +1133,42 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc,
 		{ WESTON_OPTION_INTEGER, "width", 0, &width },
 		{ WESTON_OPTION_INTEGER, "height", 0, &height },
 		{ WESTON_OPTION_INTEGER, "scale", 0, &scale },
-		{ WESTON_OPTION_STRING, "display", 0, &new_config.display_name },
-		{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &new_config.use_pixman },
+		{ WESTON_OPTION_STRING, "display", 0, &out_config->display_name },
+		{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &out_config->use_pixman },
 		{ WESTON_OPTION_INTEGER, "output-count", 0, &count },
-		{ WESTON_OPTION_BOOLEAN, "fullscreen", 0, &new_config.fullscreen },
-		{ WESTON_OPTION_BOOLEAN, "sprawl", 0, &new_config.sprawl },
+		{ WESTON_OPTION_BOOLEAN, "fullscreen", 0, &out_config->fullscreen },
+		{ WESTON_OPTION_BOOLEAN, "sprawl", 0, &out_config->sprawl },
 	};
 
 	width = 0;
 	height = 0;
 	scale = 0;
-	new_config.display_name = NULL;
-	new_config.use_pixman = 0;
+	out_config->display_name = NULL;
+	out_config->use_pixman = 0;
 	count = 1;
-	new_config.fullscreen = 0;
-	new_config.sprawl = 0;
+	out_config->fullscreen = 0;
+	out_config->sprawl = 0;
 	parse_options(wayland_options,
 		      ARRAY_LENGTH(wayland_options), argc, argv);
 
-	new_config.cursor_size = 32;
-	new_config.cursor_theme = NULL;
-	new_config.base.struct_size = sizeof(struct weston_wayland_backend_config);
-	new_config.base.struct_version = WESTON_WAYLAND_BACKEND_CONFIG_VERSION;
+	out_config->cursor_size = 32;
+	out_config->cursor_theme = NULL;
+	out_config->base.struct_size = sizeof(struct weston_wayland_backend_config);
+	out_config->base.struct_version = WESTON_WAYLAND_BACKEND_CONFIG_VERSION;
 
 	section = weston_config_get_section(wc, "shell", NULL, NULL);
 	weston_config_section_get_string(section, "cursor-theme",
-					 &new_config.cursor_theme, NULL);
+					 &out_config->cursor_theme, NULL);
 	weston_config_section_get_int(section, "cursor-size",
-				      &new_config.cursor_size, 32);
+				      &out_config->cursor_size, 32);
 
-	if (new_config.sprawl) {
+	if (out_config->sprawl) {
 		/* do nothing, everything is already set */
-		*out_config = new_config;
 		return 0;
 	}
 
-	if (new_config.fullscreen) {
-		oc = wayland_backend_config_add_new_output(&new_config);
+	if (out_config->fullscreen) {
+		oc = wayland_backend_config_add_new_output(out_config);
 		if (!oc)
 			goto err_outputs;
 
@@ -1180,7 +1178,6 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc,
 		oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
 		oc->scale = 1;
 
-		*out_config = new_config;
 		return 0;
 	}
 
@@ -1198,7 +1195,7 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc,
 		}
 		free(name);
 
-		oc = wayland_backend_config_add_new_output(&new_config);
+		oc = wayland_backend_config_add_new_output(out_config);
 
 		if (!oc)
 			goto err_outputs;
@@ -1216,7 +1213,7 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc,
 		scale = 1;
 	while (count > 0) {
 
-		oc = wayland_backend_config_add_new_output(&new_config);
+		oc = wayland_backend_config_add_new_output(out_config);
 
 		if (!oc)
 			goto err_outputs;
@@ -1230,11 +1227,10 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc,
 		--count;
 	}
 
-	*out_config = new_config;
 	return 0;
 
 err_outputs:
-	wayland_backend_config_release(&new_config);
+	wayland_backend_config_release(out_config);
 	return -1;
 }
 
-- 
2.7.3



More information about the wayland-devel mailing list