summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-04-05 14:26:08 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2007-04-05 14:26:08 +0000
commitc758a2265c90e6d4e15c1a1942f481db606e3d3e (patch)
treefea28871f4da950827980a2f9c83132afbb9a6ed
parentff04f0df98375f9e464ef0f5e02651e89872ebc2 (diff)
Fail "make check" if you declare a GError*, leave it uninitialized and don't add a comment indicating that that's OK because you'll immediately use g_error_new (g_set_error asserts when it sees uninitialized GError*s, so they should be avoided). Fix the resulting "make check" failures.
-rw-r--r--lib/telepathy-glib/Makefile.am8
-rw-r--r--lib/telepathy-glib/base-connection.c9
-rw-r--r--src/Makefile.am8
-rw-r--r--src/conn-aliasing.c2
-rw-r--r--src/conn-avatars.c4
-rw-r--r--src/conn-presence.c8
-rw-r--r--src/disco.c4
-rw-r--r--src/gabble-connection.c19
-rw-r--r--src/gabble-media-stream.c2
-rw-r--r--src/gabble-muc-channel.c2
-rw-r--r--src/gabble-register.c2
-rw-r--r--src/vcard-manager.c11
12 files changed, 45 insertions, 34 deletions
diff --git a/lib/telepathy-glib/Makefile.am b/lib/telepathy-glib/Makefile.am
index 0261507b5..3a8d8dbc9 100644
--- a/lib/telepathy-glib/Makefile.am
+++ b/lib/telepathy-glib/Makefile.am
@@ -100,6 +100,14 @@ check-local::
echo "^^^ The above files contain tabs"; \
exit 1; \
fi
+ @echo "Checking for GError mistakes..."
+ @if grep -n '^ *GError *\*[a-zA-Z_][a-zA-Z0-9_]* *;' \
+ $(whitespace_sources); \
+ then \
+ echo "^^^ The above files contain uninitialized GError*s -"; \
+ echo " they should be initialized to NULL"; \
+ exit 1; \
+ fi
libtelepathy_glib_la_SOURCES = \
base-connection.c \
diff --git a/lib/telepathy-glib/base-connection.c b/lib/telepathy-glib/base-connection.c
index fdd94ab04..a690dfa01 100644
--- a/lib/telepathy-glib/base-connection.c
+++ b/lib/telepathy-glib/base-connection.c
@@ -129,18 +129,15 @@ static void
channel_request_cancel (gpointer data, gpointer user_data)
{
ChannelRequest *request = (ChannelRequest *) data;
- GError *error;
+ GError error = { TP_ERRORS, TP_ERROR_DISCONNECTED,
+ "unable to service this channel request, we're disconnecting!" };
DEBUG ("cancelling request at %p for %s/%u/%u", request,
request->channel_type, request->handle_type, request->handle);
- error = g_error_new (TP_ERRORS, TP_ERROR_DISCONNECTED, "unable to "
- "service this channel request, we're disconnecting!");
-
- dbus_g_method_return_error (request->context, error);
+ dbus_g_method_return_error (request->context, &error);
request->context = NULL;
- g_error_free (error);
channel_request_free (request);
}
diff --git a/src/Makefile.am b/src/Makefile.am
index 7656eeed4..f876f2ebb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -110,6 +110,14 @@ check-local::
echo "^^^ The above files contain tabs"; \
exit 1; \
fi
+ @echo "Checking for GError mistakes..."
+ @if grep -n '^ *GError *\*[a-zA-Z_][a-zA-Z0-9_]* *;' \
+ $(whitespace_sources); \
+ then \
+ echo "^^^ The above files contain uninitialized GError*s -"; \
+ echo " they should be initialized to NULL"; \
+ exit 1; \
+ fi
telepathy_gabble_LDADD = libgabble-convenience.la \
$(top_builddir)/lib/telepathy-glib/libtelepathy-glib.la
diff --git a/src/conn-aliasing.c b/src/conn-aliasing.c
index 1be22ed29..1d1590c3f 100644
--- a/src/conn-aliasing.c
+++ b/src/conn-aliasing.c
@@ -335,7 +335,7 @@ gabble_connection_set_aliases (TpSvcConnectionInterfaceAliasing *iface,
{
GabbleConnection *self = GABBLE_CONNECTION (iface);
TpBaseConnection *base = (TpBaseConnection *)self;
- GError *error;
+ GError *error = NULL;
struct _i_hate_g_hash_table_foreach data = { NULL, NULL, TRUE };
g_assert (GABBLE_IS_CONNECTION (self));
diff --git a/src/conn-avatars.c b/src/conn-avatars.c
index c2fd6a22b..9a641404d 100644
--- a/src/conn-avatars.c
+++ b/src/conn-avatars.c
@@ -193,7 +193,7 @@ gabble_connection_get_avatar_tokens (TpSvcConnectionInterfaceAvatars *iface,
gboolean have_self_avatar;
guint i, my_index = 0;
gchar **ret;
- GError *err;
+ GError *err = NULL;
TpHandleRepoIface *contact_handles = tp_base_connection_get_handles (base,
TP_HANDLE_TYPE_CONTACT);
@@ -482,7 +482,7 @@ _set_avatar_cb2 (GabbleVCardManager *manager,
else
{
GabblePresence *presence = ctx->conn->self_presence;
- GError *error;
+ GError *error = NULL;
g_free (presence->avatar_sha1);
if (ctx->avatar)
diff --git a/src/conn-presence.c b/src/conn-presence.c
index d8a699263..771cbff93 100644
--- a/src/conn-presence.c
+++ b/src/conn-presence.c
@@ -220,7 +220,7 @@ gabble_connection_clear_status (TpSvcConnectionInterfacePresence *iface,
{
GabbleConnection *self = GABBLE_CONNECTION (iface);
TpBaseConnection *base = (TpBaseConnection *)self;
- GError *error;
+ GError *error = NULL;
gboolean ok;
gchar *resource;
gint8 priority;
@@ -413,7 +413,7 @@ gabble_connection_remove_status (TpSvcConnectionInterfacePresence *iface,
GabbleConnection *self = GABBLE_CONNECTION (iface);
TpBaseConnection *base = (TpBaseConnection *)self;
GabblePresence *presence = self->self_presence;
- GError *error;
+ GError *error = NULL;
gchar *resource;
gint8 priority;
@@ -466,7 +466,7 @@ gabble_connection_request_presence (TpSvcConnectionInterfacePresence *iface,
{
GabbleConnection *self = GABBLE_CONNECTION (iface);
TpBaseConnection *base = (TpBaseConnection *)self;
- GError *error;
+ GError *error = NULL;
TpHandleRepoIface *contact_handles = tp_base_connection_get_handles (base,
TP_HANDLE_TYPE_CONTACT);
@@ -618,7 +618,7 @@ gabble_connection_set_status (TpSvcConnectionInterfacePresence *iface,
GabbleConnection *self = GABBLE_CONNECTION (iface);
TpBaseConnection *base = (TpBaseConnection *)self;
struct _i_hate_g_hash_table_foreach data = { NULL, NULL, TRUE };
- GError *error;
+ GError *error = NULL;
g_assert (GABBLE_IS_CONNECTION (self));
diff --git a/src/disco.c b/src/disco.c
index a45b8dea7..99f014476 100644
--- a/src/disco.c
+++ b/src/disco.c
@@ -293,7 +293,7 @@ static gboolean
timeout_request (gpointer data)
{
GabbleDiscoRequest *request = (GabbleDiscoRequest*) data;
- GError *err;
+ GError *err /* doesn't need initializing */;
g_return_val_if_fail (data != NULL, FALSE);
err = g_error_new (GABBLE_DISCO_ERROR, GABBLE_DISCO_ERROR_TIMEOUT,
@@ -312,7 +312,7 @@ timeout_request (gpointer data)
static void
cancel_request (GabbleDiscoRequest *request)
{
- GError *err;
+ GError *err /* doesn't need initializing */;
g_assert (request != NULL);
diff --git a/src/gabble-connection.c b/src/gabble-connection.c
index 1468aebe1..4135b3314 100644
--- a/src/gabble-connection.c
+++ b/src/gabble-connection.c
@@ -1989,7 +1989,7 @@ connection_disco_cb (GabbleDisco *disco,
GabbleConnection *conn = user_data;
TpBaseConnection *base = (TpBaseConnection *)conn;
GabbleConnectionPrivate *priv;
- GError *error;
+ GError *error = NULL;
if (base->status != TP_CONNECTION_STATUS_CONNECTING)
{
@@ -2177,7 +2177,7 @@ gabble_connection_advertise_capabilities (TpSvcConnectionInterfaceCapabilities *
GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (self);
const CapabilityConversionData *ccd;
GPtrArray *ret;
- GError *error;
+ GError *error = NULL;
TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
@@ -2296,7 +2296,7 @@ gabble_connection_get_capabilities (TpSvcConnectionInterfaceCapabilities *iface,
TP_HANDLE_TYPE_CONTACT);
guint i;
GPtrArray *ret;
- GError *error;
+ GError *error = NULL;
TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
@@ -2512,12 +2512,11 @@ room_verify_batch_new (GabbleConnection *conn,
if (!qualified_name)
{
- GError *error;
- DEBUG ("requested handle %s contains no conference server",
- name);
- error = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "requested "
- "room handle %s does not specify a server, but we have not discovered "
- "any local conference servers and no fallback was provided", name);
+ GError *error = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
+ "requested room handle %s does not specify a server, but we "
+ "have not discovered any local conference servers and no "
+ "fallback was provided", name);
+ DEBUG ("%s", error->message);
room_verify_batch_raise_error (batch, error);
return NULL;
}
@@ -2674,7 +2673,7 @@ room_jid_verify (RoomVerifyBatch *batch,
{
gchar *room, *service;
gboolean ret;
- GError *error;
+ GError *error = NULL;
room = service = NULL;
gabble_decode_jid (batch->contexts[index].jid, &room, &service, NULL);
diff --git a/src/gabble-media-stream.c b/src/gabble-media-stream.c
index c09ef889f..dc719cc7d 100644
--- a/src/gabble-media-stream.c
+++ b/src/gabble-media-stream.c
@@ -627,7 +627,7 @@ gabble_media_stream_error_async (TpSvcMediaStreamHandler *iface,
DBusGMethodInvocation *context)
{
GabbleMediaStream *self = GABBLE_MEDIA_STREAM (iface);
- GError *error;
+ GError *error = NULL;
if (gabble_media_stream_error (self, errno, message, &error))
{
diff --git a/src/gabble-muc-channel.c b/src/gabble-muc-channel.c
index 2b3f0a1c9..b2a3a5efa 100644
--- a/src/gabble-muc-channel.c
+++ b/src/gabble-muc-channel.c
@@ -1169,7 +1169,7 @@ _gabble_muc_channel_presence_error (GabbleMucChannel *chan,
}
else
{
- GError *tp_error;
+ GError *tp_error /* doesn't need initializing */;
switch (error) {
case XMPP_ERROR_FORBIDDEN:
diff --git a/src/gabble-register.c b/src/gabble-register.c
index 8cf8e741b..8e05dae09 100644
--- a/src/gabble-register.c
+++ b/src/gabble-register.c
@@ -484,7 +484,7 @@ send_registration (GabbleRegister *reg, RegistrationStage stage)
GabbleRegisterPrivate *priv = GABBLE_REGISTER_GET_PRIVATE (reg);
LmMessage *msg;
LmMessageNode *node;
- GError *error;
+ GError *error = NULL;
GabbleConnectionMsgReplyFunc handler;
msg = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
diff --git a/src/vcard-manager.c b/src/vcard-manager.c
index 80c602c41..fb6f46308 100644
--- a/src/vcard-manager.c
+++ b/src/vcard-manager.c
@@ -714,11 +714,11 @@ static gboolean
timeout_request (gpointer data)
{
GabbleVCardManagerRequest *request = (GabbleVCardManagerRequest*) data;
- GError *err;
+ GError *err /* doesn't need initializing */;
g_return_val_if_fail (data != NULL, FALSE);
- err = g_error_new (GABBLE_VCARD_MANAGER_ERROR, GABBLE_VCARD_MANAGER_ERROR_TIMEOUT,
- "Request timed out");
+ err = g_error_new (GABBLE_VCARD_MANAGER_ERROR,
+ GABBLE_VCARD_MANAGER_ERROR_TIMEOUT, "Request timed out");
DEBUG ("Request %p timed out, notifying callback %p",
request, request->callback);
@@ -730,12 +730,11 @@ timeout_request (gpointer data)
static void
cancel_request (GabbleVCardManagerRequest *request)
{
- GError *err;
+ GError *err = g_error_new (GABBLE_VCARD_MANAGER_ERROR,
+ GABBLE_VCARD_MANAGER_ERROR_CANCELLED, "Request cancelled");
g_assert (request != NULL);
- err = g_error_new (GABBLE_VCARD_MANAGER_ERROR, GABBLE_VCARD_MANAGER_ERROR_CANCELLED,
- "Request cancelled");
DEBUG ("Request %p cancelled, notifying callback %p",
request, request->callback);