[PATCH weston v3 02/17] compositor-wayland: add versionning to config structure

Pekka Paalanen ppaalanen at gmail.com
Fri May 6 14:26:23 UTC 2016


On Thu,  5 May 2016 22:45:40 +0200
Benoit Gschwind <gschwind at gnu-log.net> wrote:

> Signed-off-by: Benoit Gschwind <gschwind at gnu-log.net>
> ---
>  src/compositor-wayland.c | 27 ++++++++++++++++++++++++---
>  src/compositor-wayland.h |  3 +++
>  2 files changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
> index 83f31de..b51467d 100644
> --- a/src/compositor-wayland.c
> +++ b/src/compositor-wayland.c
> @@ -2360,7 +2360,7 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc, cha
>  	     struct weston_config *config,
>  	     struct weston_wayland_backend_config *out_config)
>  {
> -	struct weston_wayland_backend_config new_config = { 0, };
> +	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;
> @@ -2391,6 +2391,8 @@ load_wayland_backend_config(struct weston_compositor *compositor, int *argc, cha
>  
>  	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;
>  
>  	section = weston_config_get_section(config, "shell", NULL, NULL);
>  	weston_config_section_get_string(section, "cursor-theme",
> @@ -2473,6 +2475,11 @@ err_outputs:
>  	return -1;
>  }
>  
> +static void
> +config_init_to_defaults(struct weston_wayland_backend_config *config)
> +{
> +}
> +
>  WL_EXPORT int
>  backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
>  	     struct weston_config *config,
> @@ -2482,14 +2489,28 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
>  	struct wayland_output *output;
>  	struct wayland_parent_output *poutput;
>  	struct weston_wayland_backend_config new_config;
> +	struct weston_wayland_backend_config foreign_config = {{ 0, }};
>  	int x, count;
>  
>  	if (load_wayland_backend_config(compositor, argc, argv, config,
> -					&new_config) < 0) {
> -		wayland_backend_config_release(&new_config);
> +					&foreign_config) < 0) {
> +		wayland_backend_config_release(&foreign_config);
>  		return -1;
>  	}
>  
> +	config_base = &foreign_config.base;

Hi,

this is a bit unusual, but ok, it is convenient to have this code here
temporarily. There should be a code comment explaining the overwrite of
config_base.

The commit message of this patch should explain that it adds this bit
of temporary code, and tell which patch then removes it. It would be
good to have a note about this patch in that patch's message, too.

With the commit messages written, this gets:
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq

> +
> +	if (config_base == NULL ||
> +	    config_base->struct_version != WESTON_WAYLAND_BACKEND_CONFIG_VERSION ||
> +	    config_base->struct_size > sizeof(struct weston_wayland_backend_config)) {
> +		weston_log("wayland backend config structure is invalid\n");
> +		wayland_backend_config_release(&foreign_config);
> +		return -1;
> +	}
> +
> +	config_init_to_defaults(&new_config);
> +	memcpy(&new_config, config_base, config_base->struct_size);
> +
>  	b = wayland_backend_create(compositor, &new_config, argc, argv, config);
>  
>  	if (!b)
> diff --git a/src/compositor-wayland.h b/src/compositor-wayland.h
> index 5af5ea7..de69b98 100644
> --- a/src/compositor-wayland.h
> +++ b/src/compositor-wayland.h
> @@ -32,6 +32,8 @@
>  extern "C" {
>  #endif
>  
> +#define WESTON_WAYLAND_BACKEND_CONFIG_VERSION 1
> +
>  struct weston_wayland_backend_output_config {
>  	int width;
>  	int height;
> @@ -41,6 +43,7 @@ struct weston_wayland_backend_output_config {
>  };
>  
>  struct weston_wayland_backend_config {
> +	struct weston_backend_config base;
>  	int use_pixman;
>  	int sprawl;
>  	char *display_name;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160506/ad2daf88/attachment.sig>


More information about the wayland-devel mailing list