From a3afd8538440bc93642dad243ff7ce51732d094b Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 21 May 2014 10:50:40 +0200 Subject: [PATCH] ensure that values received from callback are not NULL Make clang happier and is safer anyway. https://bugs.freedesktop.org/show_bug.cgi?id=79006 --- telepathy-glib/account.c | 10 ++++++---- telepathy-glib/base-room-config.c | 2 ++ telepathy-glib/connection.c | 1 + telepathy-glib/debug-client.c | 2 ++ telepathy-glib/gnio-util.c | 2 ++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c index 8fd7c55..c245b6b 100644 --- a/telepathy-glib/account.c +++ b/telepathy-glib/account.c @@ -3306,21 +3306,23 @@ tp_account_get_supersedes (TpAccount *self) static void _tp_account_got_avatar_cb (TpProxy *proxy, - const GValue *out_Value, + const GValue *value, const GError *error, gpointer user_data, GObject *weak_object) { GTask *task = user_data; + g_return_if_fail (error != NULL || value != NULL); + if (error != NULL) { DEBUG ("Failed to get avatar: %s", error->message); g_task_return_error (task, g_error_copy (error)); } - else if (!G_VALUE_HOLDS (out_Value, TP_STRUCT_TYPE_AVATAR)) + else if (!G_VALUE_HOLDS (value, TP_STRUCT_TYPE_AVATAR)) { - DEBUG ("Avatar had wrong type: %s", G_VALUE_TYPE_NAME (out_Value)); + DEBUG ("Avatar had wrong type: %s", G_VALUE_TYPE_NAME (value)); g_task_return_new_error (task, TP_ERROR, TP_ERROR_CONFUSED, "Incorrect type for Avatar property"); } @@ -3328,7 +3330,7 @@ _tp_account_got_avatar_cb (TpProxy *proxy, { /* we just put the GValueArray in the task, and use a non-trivial * finish function to split it into data and MIME type */ - g_task_return_pointer (task, g_value_dup_boxed (out_Value), + g_task_return_pointer (task, g_value_dup_boxed (value), (GDestroyNotify) tp_value_array_free); } diff --git a/telepathy-glib/base-room-config.c b/telepathy-glib/base-room-config.c index 1973b97..8055068 100644 --- a/telepathy-glib/base-room-config.c +++ b/telepathy-glib/base-room-config.c @@ -759,6 +759,8 @@ validate_property_type ( static TpDBusPropertiesMixinIfaceInfo *iface_info = NULL; TpDBusPropertiesMixinPropInfo *prop_info; + g_return_val_if_fail (value != NULL, FALSE); + if (G_UNLIKELY (iface_info == NULL)) iface_info = tp_svc_interface_get_dbus_properties_info ( TP_TYPE_SVC_CHANNEL_INTERFACE_ROOM_CONFIG1); diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c index 93c1a11..f88611f 100644 --- a/telepathy-glib/connection.c +++ b/telepathy-glib/connection.c @@ -525,6 +525,7 @@ tp_connection_get_rcc_cb (TpProxy *proxy, goto finally; } + g_return_if_fail (value != NULL); g_assert (self->priv->capabilities == NULL); if (!G_VALUE_HOLDS (value, TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST)) diff --git a/telepathy-glib/debug-client.c b/telepathy-glib/debug-client.c index 4eb2811..4350db2 100644 --- a/telepathy-glib/debug-client.c +++ b/telepathy-glib/debug-client.c @@ -268,6 +268,8 @@ got_enabled_cb ( { TpDebugClient *self = TP_DEBUG_CLIENT (proxy); + g_return_if_fail (error != NULL || value != NULL); + if (error != NULL) { tp_proxy_invalidate (proxy, error); diff --git a/telepathy-glib/gnio-util.c b/telepathy-glib/gnio-util.c index d3d5f73..994428c 100644 --- a/telepathy-glib/gnio-util.c +++ b/telepathy-glib/gnio-util.c @@ -82,6 +82,8 @@ tp_g_socket_address_from_variant (TpSocketAddressType type, { GSocketAddress *addr; + g_return_val_if_fail (variant != NULL, NULL); + switch (type) { #ifdef HAVE_GIO_UNIX -- 1.9.3