[Spice-devel] [PATCH spice-server v3] tests: Apply same warning level as main server code
Christophe Fergeau
cfergeau at redhat.com
Tue Dec 6 16:11:36 UTC 2016
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
On Tue, Dec 06, 2016 at 03:05:48PM +0000, Frediano Ziglio wrote:
> 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 <fziglio at redhat.com>
> ---
> 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 +-
> server/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(-)
>
> Changes sinve v2:
> - fix typos;
> - extend commit message;
> - add a comment in the code to make clear the reason for
> declaration.
>
> Changes since v1:
> - was "Compile all tests with same warning level of main server code";
> - extend commit message.
>
> diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
> index 8995859..3870b9e 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 b2b2136..7bda79a 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 bf1475d..8167df5 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 8b3a09b..f4a5bea 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 b68a648..c0aa38f 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 6e945fd..05a6d12 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 dc44282..10a55b8 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 da98488..0df551d 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 7dab278..564d42a 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 a3fa345..7f905ad 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);
> --
> 2.9.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161206/9976e9ea/attachment.sig>
More information about the Spice-devel
mailing list