[PATCH 1/2] server: Split out varargs version of wl_resource_post_error.

Pekka Paalanen ppaalanen at gmail.com
Wed Feb 21 08:00:52 UTC 2018


On Tue, 20 Feb 2018 18:07:26 +1100
raof at ubuntu.com wrote:

> From: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
> 
> This will allow other wrappers around wl_resource_post_error to accept
> variable argument lists.
> 
> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
> ---
>  src/wayland-server.c | 23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index eb1e500..00c93f7 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -273,17 +273,14 @@ wl_resource_queue_event(struct wl_resource *resource, uint32_t opcode, ...)
>  	wl_resource_queue_event_array(resource, opcode, args);
>  }
>  
> -WL_EXPORT void
> -wl_resource_post_error(struct wl_resource *resource,
> -		       uint32_t code, const char *msg, ...)
> +static void
> +wl_resource_post_error_vargs(struct wl_resource *resource,
> +			     uint32_t code, const char *msg, va_list argp)
>  {
>  	struct wl_client *client = resource->client;
>  	char buffer[128];
> -	va_list ap;
>  
> -	va_start(ap, msg);
> -	vsnprintf(buffer, sizeof buffer, msg, ap);
> -	va_end(ap);
> +	vsnprintf(buffer, sizeof buffer, msg, argp);
>  
>  	/*
>  	 * When a client aborts, its resources are destroyed in id order,
> @@ -298,6 +295,18 @@ wl_resource_post_error(struct wl_resource *resource,
>  	wl_resource_post_event(client->display_resource,
>  			       WL_DISPLAY_ERROR, resource, code, buffer);
>  	client->error = 1;
> +
> +}
> +
> +WL_EXPORT void
> +wl_resource_post_error(struct wl_resource *resource,
> +		       uint32_t code, const char *msg, ...)
> +{
> +	va_list ap;
> +
> +	va_start(ap, msg);
> +	wl_resource_post_error_vargs(resource, code, msg, ap);
> +	va_end(ap);
>  }
>  
>  static void

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


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180221/c1cf08dd/attachment-0001.sig>


More information about the wayland-devel mailing list