Fix cast-function-type warning introduced in GCC 8
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Sat, 26 May 2018 15:58:21 +0000 (15:58 +0000)
committerOlivier CrĂȘte <olivier.crete@collabora.com>
Tue, 12 Jun 2018 14:57:03 +0000 (16:57 +0200)
This is new warning introduced with GCC 8. This is being fixed by using appropriate function, like g_queue_free_full/g_list_free_full or by casting to GCallback before casting to the target function signature.

Closes: #46

agent/agent.c
agent/component.c
agent/outputstream.c
gst/gstnicesrc.c
socket/socket-priv.h
socket/socket.c
socket/tcp-bsd.c
socket/udp-turn.c

index 89e3514..ddad077 100644 (file)
@@ -2933,8 +2933,7 @@ nice_agent_gather_candidates (
       }
     }
 
-    g_list_foreach (addresses, (GFunc) g_free, NULL);
-    g_list_free (addresses);
+    g_list_free_full (addresses, (GDestroyNotify) g_free);
   } else {
     for (i = agent->local_addresses; i; i = i->next) {
       NiceAddress *addr = i->data;
@@ -4449,7 +4448,8 @@ nice_agent_recv_messages_blocking_or_nonblocking (NiceAgent *agent,
   if (cancellable != NULL) {
     cancellable_source = g_cancellable_source_new (cancellable);
     g_source_set_callback (cancellable_source,
-        (GSourceFunc) nice_agent_recv_cancelled_cb, &child_error, NULL);
+        (GSourceFunc) G_CALLBACK (nice_agent_recv_cancelled_cb), &child_error,
+        NULL);
     g_source_attach (cancellable_source, context);
   }
 
index 6eee90e..3794c3d 100644 (file)
@@ -115,7 +115,7 @@ socket_source_attach (SocketSource *socket_source, GMainContext *context)
   /* Create a source. */
   source = g_socket_create_source (socket_source->socket->fileno,
       G_IO_IN, NULL);
-  g_source_set_callback (source, (GSourceFunc) component_io_cb,
+  g_source_set_callback (source, (GSourceFunc) G_CALLBACK (component_io_cb),
       socket_source, NULL);
 
   /* Add the source. */
@@ -1300,7 +1300,7 @@ component_source_dispatch (GSource *source, GSourceFunc callback,
     gpointer user_data)
 {
   ComponentSource *component_source = (ComponentSource *) source;
-  GPollableSourceFunc func = (GPollableSourceFunc) callback;
+  GPollableSourceFunc func = (GPollableSourceFunc) G_CALLBACK (callback);
 
   return func (component_source->pollable_stream, user_data);
 }
@@ -1349,7 +1349,7 @@ static GSourceFuncs component_source_funcs = {
   NULL,  /* check */
   component_source_dispatch,
   component_source_finalize,
-  (GSourceFunc) component_source_closure_callback,
+  (GSourceFunc) G_CALLBACK (component_source_closure_callback),
 };
 
 /**
index 4c918a7..391ab33 100644 (file)
@@ -418,7 +418,7 @@ nice_output_stream_write (GOutputStream *stream, const void *buffer, gsize count
   writeable_id = g_signal_connect_data (G_OBJECT (agent),
       "reliable-transport-writable",
       (GCallback) reliable_transport_writeable_cb, write_data_ref (write_data),
-      (GClosureNotify) write_data_unref, 0);
+      (GClosureNotify) G_CALLBACK (write_data_unref), 0);
 
 
   do {
index d369e09..a3f223e 100644 (file)
@@ -327,8 +327,7 @@ gst_nice_src_dispose (GObject *object)
   src->mainctx = NULL;
 
   if (src->outbufs) {
-    g_queue_foreach (src->outbufs, (GFunc) gst_buffer_unref, NULL);
-    g_queue_free (src->outbufs);
+    g_queue_free_full (src->outbufs, (GDestroyNotify) gst_buffer_unref);
   }
   src->outbufs = NULL;
 
@@ -430,8 +429,7 @@ gst_nice_src_change_state (GstElement * element, GstStateChange transition)
       nice_agent_attach_recv (src->agent, src->stream_id, src->component_id,
           src->mainctx, NULL, NULL);
       GST_OBJECT_LOCK (src);
-      g_queue_foreach (src->outbufs, (GFunc) gst_buffer_unref, NULL);
-      g_queue_clear (src->outbufs);
+      g_queue_free_full (src->outbufs, (GDestroyNotify) gst_buffer_unref);
       GST_OBJECT_UNLOCK (src);
       break;
     case GST_STATE_CHANGE_READY_TO_PAUSED:
index 10286e3..6e9f3f5 100644 (file)
@@ -75,7 +75,7 @@ void nice_socket_queue_send (GQueue *send_queue, const NiceAddress *to,
 void nice_socket_queue_send_with_callback (GQueue *send_queue,
     const NiceOutputMessage *message, gsize message_offset, gsize message_len,
     gboolean head, GSocket *gsock, GSource **io_source, GMainContext *context,
-    GSourceFunc cb, gpointer user_data);
+    GSocketSourceFunc cb, gpointer user_data);
 
 /**
  * nice_socket_flush_send_queue:
index 08ae31a..684e88b 100644 (file)
@@ -340,7 +340,7 @@ nice_socket_queue_send (GQueue *send_queue, const NiceAddress *to,
 void nice_socket_queue_send_with_callback (GQueue *send_queue,
     const NiceOutputMessage *message, gsize message_offset, gsize message_len,
     gboolean head, GSocket *gsock, GSource **io_source, GMainContext *context,
-    GSourceFunc cb, gpointer user_data)
+    GSocketSourceFunc cb, gpointer user_data)
 {
   NiceSocketQueuedSend *tbs;
   guint j;
@@ -360,7 +360,7 @@ void nice_socket_queue_send_with_callback (GQueue *send_queue,
 
   if (io_source && gsock && context && cb && *io_source == NULL) {
     *io_source = g_socket_create_source(gsock, G_IO_OUT, NULL);
-    g_source_set_callback (*io_source, (GSourceFunc) cb, user_data, NULL);
+    g_source_set_callback (*io_source, (GSourceFunc) G_CALLBACK (cb), user_data, NULL);
     g_source_attach (*io_source, context);
   }
 
@@ -450,6 +450,5 @@ gboolean nice_socket_flush_send_queue_to_socket (GSocket *gsock,
 void
 nice_socket_free_send_queue (GQueue *send_queue)
 {
-  g_queue_foreach (send_queue, (GFunc) nice_socket_free_queued_send, NULL);
-  g_queue_clear (send_queue);
+  g_queue_free_full (send_queue, (GDestroyNotify) nice_socket_free_queued_send);
 }
index 3e5f5a8..285d323 100644 (file)
@@ -312,7 +312,7 @@ socket_send_message (NiceSocket *sock,
         /* Queue the message and send it later. */
         nice_socket_queue_send_with_callback (&priv->send_queue,
             message, 0, message_len, FALSE, sock->fileno, &priv->io_source,
-            priv->context, (GSourceFunc) socket_send_more, sock);
+            priv->context, socket_send_more, sock);
         ret = message_len;
       }
 
@@ -321,7 +321,7 @@ socket_send_message (NiceSocket *sock,
       /* Partial send. */
       nice_socket_queue_send_with_callback (&priv->send_queue,
           message, ret, message_len, TRUE, sock->fileno, &priv->io_source,
-          priv->context, (GSourceFunc) socket_send_more, sock);
+          priv->context, socket_send_more, sock);
       ret = message_len;
     }
   } else {
@@ -330,7 +330,7 @@ socket_send_message (NiceSocket *sock,
       /* Queue the message and send it later. */
       nice_socket_queue_send_with_callback (&priv->send_queue,
           message, 0, message_len, FALSE, sock->fileno, &priv->io_source,
-          priv->context, (GSourceFunc) socket_send_more, sock);
+          priv->context, socket_send_more, sock);
       ret = message_len;
     } else {
       /* non reliable send, so we shouldn't queue the message */
index 190a9ea..c6bd803 100644 (file)
@@ -274,9 +274,7 @@ socket_close (NiceSocket *sock)
   }
   g_list_free (priv->channels);
 
-  g_list_foreach (priv->pending_bindings, (GFunc) nice_address_free,
-      NULL);
-  g_list_free (priv->pending_bindings);
+  g_list_free_full (priv->pending_bindings, (GDestroyNotify) nice_address_free);
 
   if (priv->tick_source_channel_bind != NULL) {
     g_source_destroy (priv->tick_source_channel_bind);
@@ -305,8 +303,7 @@ socket_close (NiceSocket *sock)
   g_queue_free (priv->send_requests);
 
   priv_clear_permissions (priv);
-  g_list_foreach (priv->sent_permissions, (GFunc) nice_address_free, NULL);
-  g_list_free (priv->sent_permissions);
+  g_list_free_full (priv->sent_permissions, (GDestroyNotify) nice_address_free);
   g_hash_table_destroy (priv->send_data_queues);
 
   if (priv->permission_timeout_source) {
@@ -320,8 +317,7 @@ socket_close (NiceSocket *sock)
 
   g_free (priv->current_binding);
   g_free (priv->current_binding_msg);
-  g_list_foreach (priv->pending_permissions, (GFunc) g_free, NULL);
-  g_list_free(priv->pending_permissions);
+  g_list_free_full (priv->pending_permissions, g_free);
   g_free (priv->username);
   g_free (priv->password);
   g_free (priv->cached_realm);
@@ -546,8 +542,7 @@ priv_remove_sent_permission_for_peer (UdpTurnPriv *priv, const NiceAddress *peer
 static void
 priv_clear_permissions (UdpTurnPriv *priv)
 {
-  g_list_foreach (priv->permissions, (GFunc) nice_address_free, NULL);
-  g_list_free (priv->permissions);
+  g_list_free_full (priv->permissions, (GDestroyNotify) nice_address_free);
   priv->permissions = NULL;
 }