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

Emil Velikov emil.l.velikov at gmail.com
Thu Jun 14 15:49:45 UTC 2018


---
 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,
 };
 
 static const struct wl_message wl_registry_requests[] = {
@@ -173,8 +174,8 @@ static const struct wl_message wl_registry_events[] = {
 
 WL_EXPORT const struct wl_interface wl_registry_interface = {
 	.name = "wl_registry", .version = 1,
-	.method_count = 1, .methods = wl_registry_requests,
-	.event_count = 2, .events = wl_registry_events,
+	.method_count = ARRAY_SIZE(wl_registry_requests), .methods = wl_registry_requests,
+	.event_count = ARRAY_SIZE(wl_registry_events), .events = wl_registry_events,
 };
 
 static const struct wl_message wl_callback_events[] = {
@@ -183,7 +184,7 @@ static const struct wl_message wl_callback_events[] = {
 
 WL_EXPORT const struct wl_interface wl_callback_interface = {
 	.name = "wl_callback", .version = 1,
-	.event_count = 1, .events = wl_callback_events,
+	.event_count = ARRAY_SIZE(wl_callback_events), .events = wl_callback_events,
 };
 
 static const struct wl_message wl_compositor_requests[] = {
@@ -193,7 +194,7 @@ static const struct wl_message wl_compositor_requests[] = {
 
 WL_EXPORT const struct wl_interface wl_compositor_interface = {
 	.name = "wl_compositor", .version = 4,
-	.method_count = 2, .methods = wl_compositor_requests,
+	.method_count = ARRAY_SIZE(wl_compositor_requests), .methods = wl_compositor_requests,
 };
 
 static const struct wl_message wl_shm_pool_requests[] = {
@@ -204,7 +205,7 @@ static const struct wl_message wl_shm_pool_requests[] = {
 
 WL_EXPORT const struct wl_interface wl_shm_pool_interface = {
 	.name = "wl_shm_pool", .version = 1,
-	.method_count = 3, .methods = wl_shm_pool_requests,
+	.method_count = ARRAY_SIZE(wl_shm_pool_requests), .methods = wl_shm_pool_requests,
 };
 
 static const struct wl_message wl_shm_requests[] = {
@@ -217,8 +218,8 @@ static const struct wl_message wl_shm_events[] = {
 
 WL_EXPORT const struct wl_interface wl_shm_interface = {
 	.name = "wl_shm", .version = 1,
-	.method_count = 1, .methods = wl_shm_requests,
-	.event_count = 1, .events = wl_shm_events,
+	.method_count = ARRAY_SIZE(wl_shm_requests), .methods = wl_shm_requests,
+	.event_count = ARRAY_SIZE(wl_shm_events), .events = wl_shm_events,
 };
 
 static const struct wl_message wl_buffer_requests[] = {
@@ -231,8 +232,8 @@ static const struct wl_message wl_buffer_events[] = {
 
 WL_EXPORT const struct wl_interface wl_buffer_interface = {
 	.name = "wl_buffer", .version = 1,
-	.method_count = 1, .methods = wl_buffer_requests,
-	.event_count = 1, .events = wl_buffer_events,
+	.method_count = ARRAY_SIZE(wl_buffer_requests), .methods = wl_buffer_requests,
+	.event_count = ARRAY_SIZE(wl_buffer_events), .events = wl_buffer_events,
 };
 
 static const struct wl_message wl_data_offer_requests[] = {
@@ -251,8 +252,8 @@ static const struct wl_message wl_data_offer_events[] = {
 
 WL_EXPORT const struct wl_interface wl_data_offer_interface = {
 	.name = "wl_data_offer", .version = 3,
-	.method_count = 5, .methods = wl_data_offer_requests,
-	.event_count = 3, .events = wl_data_offer_events,
+	.method_count = ARRAY_SIZE(wl_data_offer_requests), .methods = wl_data_offer_requests,
+	.event_count = ARRAY_SIZE(wl_data_offer_events), .events = wl_data_offer_events,
 };
 
 static const struct wl_message wl_data_source_requests[] = {
@@ -272,8 +273,8 @@ static const struct wl_message wl_data_source_events[] = {
 
 WL_EXPORT const struct wl_interface wl_data_source_interface = {
 	.name = "wl_data_source", .version = 3,
-	.method_count = 3, .methods = wl_data_source_requests,
-	.event_count = 6, .events = wl_data_source_events,
+	.method_count = ARRAY_SIZE(wl_data_source_requests), .methods = wl_data_source_requests,
+	.event_count = ARRAY_SIZE(wl_data_source_events), .events = wl_data_source_events,
 };
 
 static const struct wl_message wl_data_device_requests[] = {
@@ -293,8 +294,8 @@ static const struct wl_message wl_data_device_events[] = {
 
 WL_EXPORT const struct wl_interface wl_data_device_interface = {
 	.name = "wl_data_device", .version = 3,
-	.method_count = 3, .methods = wl_data_device_requests,
-	.event_count = 6, .events = wl_data_device_events,
+	.method_count = ARRAY_SIZE(wl_data_device_requests), .methods = wl_data_device_requests,
+	.event_count = ARRAY_SIZE(wl_data_device_events), .events = wl_data_device_events,
 };
 
 static const struct wl_message wl_data_device_manager_requests[] = {
@@ -304,7 +305,7 @@ static const struct wl_message wl_data_device_manager_requests[] = {
 
 WL_EXPORT const struct wl_interface wl_data_device_manager_interface = {
 	.name = "wl_data_device_manager", .version = 3,
-	.method_count = 2, .methods = wl_data_device_manager_requests,
+	.method_count = ARRAY_SIZE(wl_data_device_manager_requests), .methods = wl_data_device_manager_requests,
 };
 
 static const struct wl_message wl_shell_requests[] = {
@@ -313,7 +314,7 @@ static const struct wl_message wl_shell_requests[] = {
 
 WL_EXPORT const struct wl_interface wl_shell_interface = {
 	.name = "wl_shell", .version = 1,
-	.method_count = 1, .methods = wl_shell_requests,
+	.method_count = ARRAY_SIZE(wl_shell_requests), .methods = wl_shell_requests,
 };
 
 static const struct wl_message wl_shell_surface_requests[] = {
@@ -337,8 +338,8 @@ static const struct wl_message wl_shell_surface_events[] = {
 
 WL_EXPORT const struct wl_interface wl_shell_surface_interface = {
 	.name = "wl_shell_surface", .version = 1,
-	.method_count = 10, .methods = wl_shell_surface_requests,
-	.event_count = 3, .events = wl_shell_surface_events,
+	.method_count = ARRAY_SIZE(wl_shell_surface_requests), .methods = wl_shell_surface_requests,
+	.event_count = ARRAY_SIZE(wl_shell_surface_events), .events = wl_shell_surface_events,
 };
 
 static const struct wl_message wl_surface_requests[] = {
@@ -361,8 +362,8 @@ static const struct wl_message wl_surface_events[] = {
 
 WL_EXPORT const struct wl_interface wl_surface_interface = {
 	.name = "wl_surface", .version = 4,
-	.method_count = 10, .methods = wl_surface_requests,
-	.event_count = 2, .events = wl_surface_events,
+	.method_count = ARRAY_SIZE(wl_surface_requests), .methods = wl_surface_requests,
+	.event_count = ARRAY_SIZE(wl_surface_events), .events = wl_surface_events,
 };
 
 static const struct wl_message wl_seat_requests[] = {
@@ -379,8 +380,8 @@ static const struct wl_message wl_seat_events[] = {
 
 WL_EXPORT const struct wl_interface wl_seat_interface = {
 	.name = "wl_seat", .version = 6,
-	.method_count = 4, .methods = wl_seat_requests,
-	.event_count = 2, .events = wl_seat_events,
+	.method_count = ARRAY_SIZE(wl_seat_requests), .methods = wl_seat_requests,
+	.event_count = ARRAY_SIZE(wl_seat_events), .events = wl_seat_events,
 };
 
 static const struct wl_message wl_pointer_requests[] = {
@@ -402,8 +403,8 @@ static const struct wl_message wl_pointer_events[] = {
 
 WL_EXPORT const struct wl_interface wl_pointer_interface = {
 	.name = "wl_pointer", .version = 6,
-	.method_count = 2, .methods = wl_pointer_requests,
-	.event_count = 9, .events = wl_pointer_events,
+	.method_count = ARRAY_SIZE(wl_pointer_requests), .methods = wl_pointer_requests,
+	.event_count = ARRAY_SIZE(wl_pointer_events), .events = wl_pointer_events,
 };
 
 static const struct wl_message wl_keyboard_requests[] = {
@@ -421,8 +422,8 @@ static const struct wl_message wl_keyboard_events[] = {
 
 WL_EXPORT const struct wl_interface wl_keyboard_interface = {
 	.name = "wl_keyboard", .version = 6,
-	.method_count = 1, .methods = wl_keyboard_requests,
-	.event_count = 6, .events = wl_keyboard_events,
+	.method_count = ARRAY_SIZE(wl_keyboard_requests), .methods = wl_keyboard_requests,
+	.event_count = ARRAY_SIZE(wl_keyboard_events), .events = wl_keyboard_events,
 };
 
 static const struct wl_message wl_touch_requests[] = {
@@ -441,8 +442,8 @@ static const struct wl_message wl_touch_events[] = {
 
 WL_EXPORT const struct wl_interface wl_touch_interface = {
 	.name = "wl_touch", .version = 6,
-	.method_count = 1, .methods = wl_touch_requests,
-	.event_count = 7, .events = wl_touch_events,
+	.method_count = ARRAY_SIZE(wl_touch_requests), .methods = wl_touch_requests,
+	.event_count = ARRAY_SIZE(wl_touch_events), .events = wl_touch_events,
 };
 
 static const struct wl_message wl_output_requests[] = {
@@ -458,8 +459,8 @@ static const struct wl_message wl_output_events[] = {
 
 WL_EXPORT const struct wl_interface wl_output_interface = {
 	.name = "wl_output", .version = 3,
-	.method_count = 1, .methods = wl_output_requests,
-	.event_count = 4, .events = wl_output_events,
+	.method_count = ARRAY_SIZE(wl_output_requests), .methods = wl_output_requests,
+	.event_count = ARRAY_SIZE(wl_output_events), .events = wl_output_events,
 };
 
 static const struct wl_message wl_region_requests[] = {
@@ -470,7 +471,7 @@ static const struct wl_message wl_region_requests[] = {
 
 WL_EXPORT const struct wl_interface wl_region_interface = {
 	.name = "wl_region", .version = 1,
-	.method_count = 3, .methods = wl_region_requests,
+	.method_count = ARRAY_SIZE(wl_region_requests), .methods = wl_region_requests,
 };
 
 static const struct wl_message wl_subcompositor_requests[] = {
@@ -480,7 +481,7 @@ static const struct wl_message wl_subcompositor_requests[] = {
 
 WL_EXPORT const struct wl_interface wl_subcompositor_interface = {
 	.name = "wl_subcompositor", .version = 1,
-	.method_count = 2, .methods = wl_subcompositor_requests,
+	.method_count = ARRAY_SIZE(wl_subcompositor_requests), .methods = wl_subcompositor_requests,
 };
 
 static const struct wl_message wl_subsurface_requests[] = {
@@ -494,6 +495,6 @@ static const struct wl_message wl_subsurface_requests[] = {
 
 WL_EXPORT const struct wl_interface wl_subsurface_interface = {
 	.name = "wl_subsurface", .version = 1,
-	.method_count = 6, .methods = wl_subsurface_requests,
+	.method_count = ARRAY_SIZE(wl_subsurface_requests), .methods = wl_subsurface_requests,
 };
 
diff --git a/tests/data/small-code-core.c b/tests/data/small-code-core.c
index bf44cb6..9cff62e 100644
--- a/tests/data/small-code-core.c
+++ b/tests/data/small-code-core.c
@@ -43,6 +43,7 @@ static const struct wl_interface *types[] = {
 	[7] = &another_intf_interface,
 };
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 static const struct wl_message intf_A_requests[] = {
 	{ .name = "rq1", .signature = "sun", .types = &types[0] },
 	{ .name = "rq2", .signature = "nsiufho", .types = &types[1] },
@@ -55,7 +56,7 @@ static const struct wl_message intf_A_events[] = {
 
 WL_EXPORT const struct wl_interface intf_A_interface = {
 	.name = "intf_A", .version = 3,
-	.method_count = 3, .methods = intf_A_requests,
-	.event_count = 1, .events = intf_A_events,
+	.method_count = ARRAY_SIZE(intf_A_requests), .methods = intf_A_requests,
+	.event_count = ARRAY_SIZE(intf_A_events), .events = intf_A_events,
 };
 
diff --git a/tests/data/small-code.c b/tests/data/small-code.c
index bf44cb6..9cff62e 100644
--- a/tests/data/small-code.c
+++ b/tests/data/small-code.c
@@ -43,6 +43,7 @@ static const struct wl_interface *types[] = {
 	[7] = &another_intf_interface,
 };
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 static const struct wl_message intf_A_requests[] = {
 	{ .name = "rq1", .signature = "sun", .types = &types[0] },
 	{ .name = "rq2", .signature = "nsiufho", .types = &types[1] },
@@ -55,7 +56,7 @@ static const struct wl_message intf_A_events[] = {
 
 WL_EXPORT const struct wl_interface intf_A_interface = {
 	.name = "intf_A", .version = 3,
-	.method_count = 3, .methods = intf_A_requests,
-	.event_count = 1, .events = intf_A_events,
+	.method_count = ARRAY_SIZE(intf_A_requests), .methods = intf_A_requests,
+	.event_count = ARRAY_SIZE(intf_A_events), .events = intf_A_events,
 };
 
diff --git a/tests/data/small-private-code.c b/tests/data/small-private-code.c
index 88ecdb5..c334410 100644
--- a/tests/data/small-private-code.c
+++ b/tests/data/small-private-code.c
@@ -53,6 +53,7 @@ static const struct wl_interface *types[] = {
 	[7] = &another_intf_interface,
 };
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 static const struct wl_message intf_A_requests[] = {
 	{ .name = "rq1", .signature = "sun", .types = &types[0] },
 	{ .name = "rq2", .signature = "nsiufho", .types = &types[1] },
@@ -65,7 +66,7 @@ static const struct wl_message intf_A_events[] = {
 
 WL_PRIVATE const struct wl_interface intf_A_interface = {
 	.name = "intf_A", .version = 3,
-	.method_count = 3, .methods = intf_A_requests,
-	.event_count = 1, .events = intf_A_events,
+	.method_count = ARRAY_SIZE(intf_A_requests), .methods = intf_A_requests,
+	.event_count = ARRAY_SIZE(intf_A_events), .events = intf_A_events,
 };
 
-- 
2.16.0



More information about the wayland-devel mailing list