[PATCH wayland 8/8] fixup! scanner: initialize .{method, event}_count via ARRAY_SIZE

Pekka Paalanen ppaalanen at gmail.com
Tue Jul 3 11:45:54 UTC 2018


On Thu, 14 Jun 2018 16:49:45 +0100
Emil Velikov <emil.l.velikov at gmail.com> wrote:

> ---
>  tests/data/example-code.c       | 73 +++++++++++++++++++++--------------------
>  tests/data/small-code-core.c    |  5 +--
>  tests/data/small-code.c         |  5 +--
>  tests/data/small-private-code.c |  5 +--
>  4 files changed, 46 insertions(+), 42 deletions(-)
> 
> diff --git a/tests/data/example-code.c b/tests/data/example-code.c
> index 2e1f73b..65d9651 100644
> --- a/tests/data/example-code.c
> +++ b/tests/data/example-code.c
> @@ -146,6 +146,7 @@ static const struct wl_interface *types[] = {
>  	[94] = &wl_surface_interface,
>  };
>  
> +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
>  static const struct wl_message wl_display_requests[] = {
>  	{ .name = "sync", .signature = "n", .types = &types[8] },
>  	{ .name = "get_registry", .signature = "n", .types = &types[9] },
> @@ -158,8 +159,8 @@ static const struct wl_message wl_display_events[] = {
>  
>  WL_EXPORT const struct wl_interface wl_display_interface = {
>  	.name = "wl_display", .version = 1,
> -	.method_count = 2, .methods = wl_display_requests,
> -	.event_count = 2, .events = wl_display_events,
> +	.method_count = ARRAY_SIZE(wl_display_requests), .methods = wl_display_requests,
> +	.event_count = ARRAY_SIZE(wl_display_events), .events = wl_display_events,
>  };

Hi,

this change is not an obvious improvement to me. "method_count = 2" is
pretty clear, that combined with "methods = foo" does not seem to
leave anything to be desired.

If this code was hand-written, then I would be cheering for ARRAY_SIZE
for sure, but it's not. It all comes from a generator that gets the
count right.

I suppose we'd need an opinion from someone who is less familiar with
Wayland C bindings.


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/20180703/529f4c15/attachment.sig>


More information about the wayland-devel mailing list