[Spice-devel] [PATCH spice-server 1/5] tests: Reuse SPICE_N_ELEMENTS instead of COUNT
Jonathon Jongsma
jjongsma at redhat.com
Fri Sep 1 21:49:17 UTC 2017
To be honest, I'd rather just use G_N_ELEMENTS, since I think we should
eventually drop these spice reimplementations of glib utilities. But
this is OK for now
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
On Fri, 2017-09-01 at 15:12 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/tests/test-display-base.c | 2 +-
> server/tests/test-display-base.h | 2 --
> server/tests/test-display-no-ssl.c | 2 +-
> server/tests/test-display-resolution-changes.c | 2 +-
> server/tests/test-display-width-stride.c | 2 +-
> server/tests/test-two-servers.c | 4 ++--
> 6 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/server/tests/test-display-base.c b/server/tests/test-
> display-base.c
> index 88638bde..6d70da08 100644
> --- a/server/tests/test-display-base.c
> +++ b/server/tests/test-display-base.c
> @@ -468,7 +468,7 @@ int commands_end = 0;
> int commands_start = 0;
> struct QXLCommandExt* commands[1024];
>
> -#define COMMANDS_SIZE COUNT(commands)
> +#define COMMANDS_SIZE SPICE_N_ELEMENTS(commands)
>
> static void push_command(QXLCommandExt *ext)
> {
> diff --git a/server/tests/test-display-base.h b/server/tests/test-
> display-base.h
> index bdf7a11c..f4231359 100644
> --- a/server/tests/test-display-base.h
> +++ b/server/tests/test-display-base.h
> @@ -21,8 +21,6 @@
> #include <spice.h>
> #include "basic-event-loop.h"
>
> -#define COUNT(x) ((sizeof(x)/sizeof(x[0])))
> -
> /*
> * simple queue for commands.
> * each command can have up to two parameters (grow as needed)
> diff --git a/server/tests/test-display-no-ssl.c b/server/tests/test-
> display-no-ssl.c
> index f4a5bea4..ad2aece3 100644
> --- a/server/tests/test-display-no-ssl.c
> +++ b/server/tests/test-display-no-ssl.c
> @@ -61,7 +61,7 @@ int main(void)
> //spice_server_set_image_compression(server,
> SPICE_IMAGE_COMPRESSION_OFF);
> test_add_display_interface(test);
> test_add_agent_interface(test->server);
> - test_set_simple_command_list(test, simple_commands,
> COUNT(simple_commands));
> + test_set_simple_command_list(test, simple_commands,
> SPICE_N_ELEMENTS(simple_commands));
>
> ping_timer = core->timer_add(pinger, NULL);
> core->timer_start(ping_timer, ping_ms);
> diff --git a/server/tests/test-display-resolution-changes.c
> b/server/tests/test-display-resolution-changes.c
> index c0aa38ff..e9eccbe2 100644
> --- a/server/tests/test-display-resolution-changes.c
> +++ b/server/tests/test-display-resolution-changes.c
> @@ -75,7 +75,7 @@ int main(void)
> test = test_new(core);
> //spice_server_set_image_compression(server,
> SPICE_IMAGE_COMPRESSION_OFF);
> test_add_display_interface(test);
> - test_set_command_list(test, commands, COUNT(commands));
> + test_set_command_list(test, commands,
> SPICE_N_ELEMENTS(commands));
>
> ping_timer = core->timer_add(pinger, test);
> core->timer_start(ping_timer, ping_ms);
> diff --git a/server/tests/test-display-width-stride.c
> b/server/tests/test-display-width-stride.c
> index 10a55b8c..0100e1de 100644
> --- a/server/tests/test-display-width-stride.c
> +++ b/server/tests/test-display-width-stride.c
> @@ -98,7 +98,7 @@ static Command commands[] = {
>
> static void on_client_connected(Test *test)
> {
> - test_set_command_list(test, commands, COUNT(commands));
> + test_set_command_list(test, commands,
> SPICE_N_ELEMENTS(commands));
> }
>
> int main(void)
> diff --git a/server/tests/test-two-servers.c b/server/tests/test-two-
> servers.c
> index 4cf451a4..b103d54c 100644
> --- a/server/tests/test-two-servers.c
> +++ b/server/tests/test-two-servers.c
> @@ -46,8 +46,8 @@ int main(void)
> //spice_server_set_image_compression(server,
> SPICE_IMAGE_COMPRESSION_OFF);
> test_add_display_interface(t1);
> test_add_display_interface(t2);
> - test_set_simple_command_list(t1, simple_commands,
> COUNT(simple_commands));
> - test_set_simple_command_list(t2, simple_commands,
> COUNT(simple_commands));
> + test_set_simple_command_list(t1, simple_commands,
> SPICE_N_ELEMENTS(simple_commands));
> + test_set_simple_command_list(t2, simple_commands,
> SPICE_N_ELEMENTS(simple_commands));
>
> basic_event_loop_mainloop();
> return 0;
More information about the Spice-devel
mailing list