[PATCH wayland] scanner: don't emit the extern declarations for external types

Pekka Paalanen ppaalanen at gmail.com
Fri May 29 01:35:05 PDT 2015


On Thu, 28 May 2015 19:30:33 +0300
Giulio Camuffo <giuliocamuffo at gmail.com> wrote:

> We were emitting the extern declarations of all types used in the protocol,
> even if not defined in it. This caused warnings to be produced when using
> the -Wredundant-decls compiler flag when building an extension that uses
> e.g. wl_surface. However we only need the extern declarations if the
> protocol defines a factory for those external interfaces. That is a
> bad design and can be however done by including the dependent protocol
> header first.
> So only emit the extern declarations for the types that the protocol
> actually defines, this restoring the behavior we were using in 1.7.
> 
> Fixes https://bugs.freedesktop.org/show_bug.cgi?id=90677
> ---
>  src/scanner.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index 11efffc..4ab7d85 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -1089,18 +1089,14 @@ emit_header(struct protocol *protocol, enum side side)
>  		printf("struct %s;\n", *p);
>  		prev = *p;
>  	}
> +	wl_array_release(&types);
>  	printf("\n");
>  
> -	prev = NULL;
> -	wl_array_for_each(p, &types) {
> -		if (prev && strcmp(*p, prev) == 0)
> -			continue;
> +	wl_list_for_each(i, &protocol->interface_list, link) {
>  		printf("extern const struct wl_interface "
> -		       "%s_interface;\n", *p);
> -		prev = *p;
> +		       "%s_interface;\n", i->name);
>  	}
>  
> -	wl_array_release(&types);
>  	printf("\n");
>  
>  	wl_list_for_each(i, &protocol->interface_list, link) {

I diffed all the Weston's generated protocol files before and after
this patch, and the result is good.

Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

This patch can land once we get a Tested-by from rawoul.

Bryce, could you hold off with 1.8.0 until this patch has landed?
I think this is important to have in 1.8.0, because releasing the core
headers change now and adding this fix later might theoretically break
users.


Thanks,
pq


More information about the wayland-devel mailing list