summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Adam <jakub.adam@collabora.com>2019-01-07 10:31:25 +0100
committerJakub Adam <jakub.adam@collabora.com>2019-01-14 22:12:21 +0100
commit51cadfdcefb3955f8dd2816beb97a49c92bd4eae (patch)
tree32e63318b66137e9a1ab7aa3bf60caf16c80824a
parent6e27c1efa02f45fd2eb8f27615c61973a707d2f4 (diff)
downloadlibnice-51cadfdcefb3955f8dd2816beb97a49c92bd4eae.tar.gz
tests: Fix -Wcast-function-type warnings with GCC 8
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.
-rw-r--r--tests/test-build-io-stream.c4
-rw-r--r--tests/test-io-stream-common.c2
-rw-r--r--tests/test-io-stream-common.h4
-rw-r--r--tests/test-io-stream-pollable.c2
-rw-r--r--tests/test-send-recv.c4
5 files changed, 11 insertions, 5 deletions
diff --git a/tests/test-build-io-stream.c b/tests/test-build-io-stream.c
index 7a6e5dd..0ebea2f 100644
--- a/tests/test-build-io-stream.c
+++ b/tests/test-build-io-stream.c
@@ -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);
diff --git a/tests/test-io-stream-common.c b/tests/test-io-stream-common.c
index b34748d..5874cee 100644
--- a/tests/test-io-stream-common.c
+++ b/tests/test-io-stream-common.c
@@ -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);
diff --git a/tests/test-io-stream-common.h b/tests/test-io-stream-common.h
index 1e37954..680a28c 100644
--- a/tests/test-io-stream-common.h
+++ b/tests/test-io-stream-common.h
@@ -44,6 +44,10 @@
#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 */
diff --git a/tests/test-io-stream-pollable.c b/tests/test-io-stream-pollable.c
index a543f88..d747f79 100644
--- a/tests/test-io-stream-pollable.c
+++ b/tests/test-io-stream-pollable.c
@@ -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);
diff --git a/tests/test-send-recv.c b/tests/test-send-recv.c
index d853036..b3740dd 100644
--- a/tests/test-send-recv.c
+++ b/tests/test-send-recv.c
@@ -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);