tests: Fix -Wcast-function-type warnings with GCC 8
authorJakub Adam <jakub.adam@collabora.com>
Mon, 7 Jan 2019 09:31:25 +0000 (10:31 +0100)
committerJakub Adam <jakub.adam@collabora.com>
Mon, 14 Jan 2019 21:12:21 +0000 (22:12 +0100)
glib documentation says G_SOURCE_FUNC() macro should be used to suppress
the warning about incompatible function types when the function will be
cast back to the correct type before it is called by the GSource.

tests/test-build-io-stream.c
tests/test-io-stream-common.c
tests/test-io-stream-common.h
tests/test-io-stream-pollable.c
tests/test-send-recv.c

index 7a6e5dd..0ebea2f 100644 (file)
@@ -42,6 +42,8 @@
 
 #include "iostream.h"
 
+#include "test-io-stream-common.h"
+
 static void
 test_invalid_stream (NiceAddress *addr)
 {
@@ -254,7 +256,7 @@ check_pollable_source_cancellation (GSource *pollable_source,
   main_loop = g_main_loop_new (main_context, FALSE);
 
   /* Set up the pollable source. */
-  g_source_set_callback (pollable_source, (GSourceFunc) source_cancelled_cb,
+  g_source_set_callback (pollable_source, G_SOURCE_FUNC (source_cancelled_cb),
       main_loop, NULL);
   g_source_attach (pollable_source, main_context);
 
index b34748d..5874cee 100644 (file)
@@ -554,7 +554,7 @@ void
 stop_main_loop (GMainLoop *loop)
 {
   GSource *src = g_idle_source_new ();
-  g_source_set_callback (src, (GSourceFunc) g_main_loop_quit,
+  g_source_set_callback (src, G_SOURCE_FUNC (g_main_loop_quit),
       g_main_loop_ref (loop), (GDestroyNotify) g_main_loop_unref);
   g_source_attach (src, g_main_loop_get_context (loop));
   g_source_unref (src);
index 1e37954..680a28c 100644 (file)
 #include <unistd.h>
 #endif
 
+#if !GLIB_CHECK_VERSION(2, 58, 0)
+#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f))
+#endif
+
 /* Make the message sufficiently large to not hit Nagle’s algorithm in the
  * pseudo-TCP implementation, and hence run really slowly. */
 #define MESSAGE_SIZE 1284 /* bytes */
index a543f88..d747f79 100644 (file)
@@ -107,7 +107,7 @@ read_thread_cb (GInputStream *input_stream, TestIOStreamThreadData *data)
       g_pollable_input_stream_create_source (
           G_POLLABLE_INPUT_STREAM (input_stream), NULL);
 
-  g_source_set_callback (stream_source, (GSourceFunc) read_stream_cb,
+  g_source_set_callback (stream_source, G_SOURCE_FUNC (read_stream_cb),
       data, NULL);
   g_source_attach (stream_source, main_context);
   g_source_unref (stream_source);
index d853036..b3740dd 100644 (file)
@@ -954,7 +954,7 @@ read_thread_gsource_cb (GInputStream *input_stream,
       g_pollable_input_stream_create_source (
           G_POLLABLE_INPUT_STREAM (input_stream), NULL);
 
-  g_source_set_callback (stream_source, (GSourceFunc) read_stream_cb,
+  g_source_set_callback (stream_source, G_SOURCE_FUNC (read_stream_cb),
       &gsource_data, NULL);
   g_source_attach (stream_source, main_context);
 
@@ -1031,7 +1031,7 @@ write_thread_gsource_cb (GOutputStream *output_stream,
       g_pollable_output_stream_create_source (
           G_POLLABLE_OUTPUT_STREAM (output_stream), NULL);
 
-  g_source_set_callback (stream_source, (GSourceFunc) write_stream_cb,
+  g_source_set_callback (stream_source, G_SOURCE_FUNC (write_stream_cb),
       &gsource_data, NULL);
   g_source_attach (stream_source, main_context);