From 030ae7bbdcd35d64d6f62d5607a64d860f306b78 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Tue, 6 Dec 2016 15:04:15 +0000 Subject: [PATCH] tests: Apply same warning level as main server code Allow to catch minor issue with test code. Although test usually are coded with less care than production code the current changes required are not so extensive and can catch different issues. Most of the patch is making functions static to avoid warnings for undeclared functions. Signed-off-by: Frediano Ziglio Acked-by: Christophe Fergeau --- server/tests/Makefile.am | 1 + server/tests/stat-test.c | 3 ++ server/tests/test-display-base.c | 17 +++++---- server/tests/test-display-no-ssl.c | 2 +- .../tests/test-display-resolution-changes.c | 6 +-- server/tests/test-display-streaming.c | 2 +- server/tests/test-display-width-stride.c | 16 ++++---- server/tests/test-empty-success.c | 38 +++++++++++-------- server/tests/test-playback.c | 2 +- server/tests/test-vdagent.c | 2 +- 10 files changed, 51 insertions(+), 38 deletions(-) diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am index 8995859d..3870b9e6 100644 --- a/server/tests/Makefile.am +++ b/server/tests/Makefile.am @@ -11,6 +11,7 @@ AM_CPPFLAGS = \ $(SMARTCARD_CFLAGS) \ $(SPICE_NONPKGCONFIG_CFLAGS) \ $(SPICE_PROTOCOL_CFLAGS) \ + $(WARN_CFLAGS) \ $(NULL) if HAVE_AUTOMATED_TESTS diff --git a/server/tests/stat-test.c b/server/tests/stat-test.c index b2b21366..7bda79ae 100644 --- a/server/tests/stat-test.c +++ b/server/tests/stat-test.c @@ -40,6 +40,9 @@ #error TEST_NAME must be defined! #endif +// avoid warning, the function is called by stat-main.c +void TEST_NAME(void); + void TEST_NAME(void) { stat_info_t info; diff --git a/server/tests/test-display-base.c b/server/tests/test-display-base.c index bf1475dc..8167df52 100644 --- a/server/tests/test-display-base.c +++ b/server/tests/test-display-base.c @@ -165,11 +165,12 @@ static void draw_pos(Test *test, int t, int *x, int *y) } /* bitmap and rects are freed, so they must be allocated with malloc */ -SimpleSpiceUpdate *test_spice_create_update_from_bitmap(uint32_t surface_id, - QXLRect bbox, - uint8_t *bitmap, - uint32_t num_clip_rects, - QXLRect *clip_rects) +static SimpleSpiceUpdate * +test_spice_create_update_from_bitmap(uint32_t surface_id, + QXLRect bbox, + uint8_t *bitmap, + uint32_t num_clip_rects, + QXLRect *clip_rects) { SimpleSpiceUpdate *update; QXLDrawable *drawable; @@ -677,7 +678,7 @@ static struct { uint8_t data[CURSOR_WIDTH * CURSOR_HEIGHT * 4]; // 32bit per pixel } cursor; -static void cursor_init() +static void cursor_init(void) { cursor.cursor.header.unique = 0; cursor.cursor.header.type = SPICE_CURSOR_TYPE_COLOR32; @@ -878,7 +879,7 @@ Test *test_new(SpiceCoreInterface *core) return test; } -void init_automated() +static void init_automated(void) { struct sigaction sa; @@ -887,7 +888,7 @@ void init_automated() sigaction(SIGCHLD, &sa, NULL); } -__attribute__((noreturn)) +static __attribute__((noreturn)) void usage(const char *argv0, const int exitcode) { #ifdef AUTOMATED_TESTS diff --git a/server/tests/test-display-no-ssl.c b/server/tests/test-display-no-ssl.c index 8b3a09b9..f4a5bea4 100644 --- a/server/tests/test-display-no-ssl.c +++ b/server/tests/test-display-no-ssl.c @@ -34,7 +34,7 @@ void show_channels(SpiceServer *server); int ping_ms = 100; -void pinger(SPICE_GNUC_UNUSED void *opaque) +static void pinger(SPICE_GNUC_UNUSED void *opaque) { // show_channels is not thread safe - fails if disconnections / connections occur //show_channels(server); diff --git a/server/tests/test-display-resolution-changes.c b/server/tests/test-display-resolution-changes.c index b68a648f..c0aa38ff 100644 --- a/server/tests/test-display-resolution-changes.c +++ b/server/tests/test-display-resolution-changes.c @@ -30,7 +30,7 @@ void show_channels(SpiceServer *server); int ping_ms = 100; -void pinger(void *opaque) +static void pinger(void *opaque) { Test *test = opaque; // show_channels is not thread safe - fails if disconnections / connections occur @@ -39,8 +39,8 @@ void pinger(void *opaque) test->core->timer_start(ping_timer, ping_ms); } -void set_primary_params(SPICE_GNUC_UNUSED Test *test, - Command *command) +static void +set_primary_params(SPICE_GNUC_UNUSED Test *test, Command *command) { #if 0 static int toggle = 0; diff --git a/server/tests/test-display-streaming.c b/server/tests/test-display-streaming.c index 6e945fdc..05a6d126 100644 --- a/server/tests/test-display-streaming.c +++ b/server/tests/test-display-streaming.c @@ -168,7 +168,7 @@ static void create_frame1(Test *test, Command *command) create_clipped_frame(test, command, 0); } -void create_frame2(Test *test, Command *command) +static void create_frame2(Test *test, Command *command) { create_clipped_frame(test, command, 200); } diff --git a/server/tests/test-display-width-stride.c b/server/tests/test-display-width-stride.c index dc442822..10a55b8c 100644 --- a/server/tests/test-display-width-stride.c +++ b/server/tests/test-display-width-stride.c @@ -30,7 +30,7 @@ void show_channels(SpiceServer *server); int ping_ms = 100; -void pinger(void *opaque) +static void pinger(void *opaque) { Test *test = opaque; // show_channels is not thread safe - fails if disconnections / connections occur @@ -42,8 +42,8 @@ void pinger(void *opaque) static int g_surface_id = 1; static uint8_t *g_surface_data; -void set_draw_parameters(SPICE_GNUC_UNUSED Test *test, - Command *command) +static void +set_draw_parameters(SPICE_GNUC_UNUSED Test *test, Command *command) { static int count = 17; CommandDrawSolid *solid = &command->solid; @@ -56,8 +56,8 @@ void set_draw_parameters(SPICE_GNUC_UNUSED Test *test, count++; } -void set_surface_params(SPICE_GNUC_UNUSED Test *test, - Command *command) +static void +set_surface_params(SPICE_GNUC_UNUSED Test *test, Command *command) { CommandCreateSurface *create = &command->create_surface; @@ -73,8 +73,8 @@ void set_surface_params(SPICE_GNUC_UNUSED Test *test, create->data = g_surface_data; } -void set_destroy_parameters(SPICE_GNUC_UNUSED Test *test, - SPICE_GNUC_UNUSED Command *command) +static void +set_destroy_parameters(SPICE_GNUC_UNUSED Test *test, SPICE_GNUC_UNUSED Command *command) { if (g_surface_data) { free(g_surface_data); @@ -96,7 +96,7 @@ static Command commands[] = { {SIMPLE_DESTROY_SURFACE, set_destroy_parameters, .cb_opaque = NULL}, }; -void on_client_connected(Test *test) +static void on_client_connected(Test *test) { test_set_command_list(test, commands, COUNT(commands)); } diff --git a/server/tests/test-empty-success.c b/server/tests/test-empty-success.c index da984881..0df551df 100644 --- a/server/tests/test-empty-success.c +++ b/server/tests/test-empty-success.c @@ -25,46 +25,54 @@ struct SpiceTimer { int a,b; }; -SpiceTimer* timer_add(SPICE_GNUC_UNUSED SpiceTimerFunc func, - SPICE_GNUC_UNUSED void *opaque) +static SpiceTimer* +timer_add(SPICE_GNUC_UNUSED SpiceTimerFunc func, + SPICE_GNUC_UNUSED void *opaque) { static struct SpiceTimer t = {0,}; return &t; } -void timer_start(SPICE_GNUC_UNUSED SpiceTimer *timer, - SPICE_GNUC_UNUSED uint32_t ms) +static void +timer_start(SPICE_GNUC_UNUSED SpiceTimer *timer, + SPICE_GNUC_UNUSED uint32_t ms) { } -void timer_cancel(SPICE_GNUC_UNUSED SpiceTimer *timer) +static void +timer_cancel(SPICE_GNUC_UNUSED SpiceTimer *timer) { } -void timer_remove(SPICE_GNUC_UNUSED SpiceTimer *timer) +static void +timer_remove(SPICE_GNUC_UNUSED SpiceTimer *timer) { } -SpiceWatch *watch_add(SPICE_GNUC_UNUSED int fd, - SPICE_GNUC_UNUSED int event_mask, - SPICE_GNUC_UNUSED SpiceWatchFunc func, - SPICE_GNUC_UNUSED void *opaque) +static SpiceWatch * +watch_add(SPICE_GNUC_UNUSED int fd, + SPICE_GNUC_UNUSED int event_mask, + SPICE_GNUC_UNUSED SpiceWatchFunc func, + SPICE_GNUC_UNUSED void *opaque) { return NULL; } -void watch_update_mask(SPICE_GNUC_UNUSED SpiceWatch *watch, - SPICE_GNUC_UNUSED int event_mask) +static void +watch_update_mask(SPICE_GNUC_UNUSED SpiceWatch *watch, + SPICE_GNUC_UNUSED int event_mask) { } -void watch_remove(SPICE_GNUC_UNUSED SpiceWatch *watch) +static void +watch_remove(SPICE_GNUC_UNUSED SpiceWatch *watch) { } -void channel_event(SPICE_GNUC_UNUSED int event, - SPICE_GNUC_UNUSED SpiceChannelEventInfo *info) +static void +channel_event(SPICE_GNUC_UNUSED int event, + SPICE_GNUC_UNUSED SpiceChannelEventInfo *info) { } diff --git a/server/tests/test-playback.c b/server/tests/test-playback.c index 7dab2782..564d42ae 100644 --- a/server/tests/test-playback.c +++ b/server/tests/test-playback.c @@ -60,7 +60,7 @@ static void get_frame(void) : 100; } -void playback_timer_cb(SPICE_GNUC_UNUSED void *opaque) +static void playback_timer_cb(SPICE_GNUC_UNUSED void *opaque) { static int t = 0; static uint64_t last_sent_usec = 0; diff --git a/server/tests/test-vdagent.c b/server/tests/test-vdagent.c index a3fa345e..7f905ad5 100644 --- a/server/tests/test-vdagent.c +++ b/server/tests/test-vdagent.c @@ -37,7 +37,7 @@ int ping_ms = 100; #define MIN(a, b) ((a) > (b) ? (b) : (a)) #endif -void pinger(SPICE_GNUC_UNUSED void *opaque) +static void pinger(SPICE_GNUC_UNUSED void *opaque) { // show_channels is not thread safe - fails if disconnections / connections occur //show_channels(server);