On Wed, 2006-08-23 at 12:55 +0200, Mikael Hallendal wrote:
> Martyn Russell wrote:
> > Nice, I also noticed some other functions which do that. Are you
> > interested in a patch?
> 
> Sure, sounds good.

Patch attached :)

-- 
Regards,
Martyn
? checks.diff
? connection_cleanup.diff
? examples-with-google.diff
Index: loudmouth/lm-connection.c
===================================================================
RCS file: /cvs/gnome/loudmouth/loudmouth/lm-connection.c,v
retrieving revision 1.67
diff -u -r1.67 lm-connection.c
--- loudmouth/lm-connection.c	25 Jun 2006 10:28:28 -0000	1.67
+++ loudmouth/lm-connection.c	23 Aug 2006 12:32:25 -0000
@@ -1511,6 +1511,8 @@
 {
 	LmConnection *connection;
 
+	g_return_val_if_fail (context != NULL, NULL);
+
 	connection = lm_connection_new (server);
 	connection->context = context;
 
@@ -1937,7 +1939,12 @@
 	}
 
 	g_free (connection->jid);
-	connection->jid = g_strdup (jid);
+
+	if (jid) {
+		connection->jid = g_strdup (jid);
+	} else {
+		connection->jid = NULL;
+	}
 }
 
 /**
@@ -2323,6 +2330,7 @@
 			GError       **error)
 {
 	g_return_val_if_fail (connection != NULL, FALSE);
+	g_return_val_if_fail (str != NULL, FALSE);
 
 	return connection_send (connection, str, -1, error);
 }
Index: loudmouth/lm-message-handler.c
===================================================================
RCS file: /cvs/gnome/loudmouth/loudmouth/lm-message-handler.c,v
retrieving revision 1.9
diff -u -r1.9 lm-message-handler.c
--- loudmouth/lm-message-handler.c	4 Oct 2004 22:54:29 -0000	1.9
+++ loudmouth/lm-message-handler.c	23 Aug 2006 12:32:25 -0000
@@ -71,6 +71,8 @@
                         GDestroyNotify          notify)
 {
         LmMessageHandler *handler;
+
+	g_return_val_if_fail (function != NULL, NULL);
         
         handler = g_new0 (LmMessageHandler, 1);
         
@@ -110,6 +112,8 @@
 gboolean
 lm_message_handler_is_valid (LmMessageHandler *handler)
 {
+	g_return_val_if_fail (handler != NULL, FALSE);
+
 	return handler->valid;
 }
 
Index: loudmouth/lm-message-node.c
===================================================================
RCS file: /cvs/gnome/loudmouth/loudmouth/lm-message-node.c,v
retrieving revision 1.11
diff -u -r1.11 lm-message-node.c
--- loudmouth/lm-message-node.c	22 Aug 2006 17:57:59 -0000	1.11
+++ loudmouth/lm-message-node.c	23 Aug 2006 12:32:25 -0000
@@ -177,6 +177,9 @@
 {
 	LmMessageNode *child;
 	
+        g_return_val_if_fail (node != NULL, NULL);
+        g_return_val_if_fail (name != NULL, NULL);
+
 	child = _lm_message_node_new (name);
 
 	lm_message_node_set_value (child, value);
@@ -234,6 +237,10 @@
 	gboolean  found = FALSE; 
 	GSList   *l;
 
+        g_return_if_fail (node != NULL);
+        g_return_if_fail (name != NULL);
+        g_return_if_fail (value != NULL);
+
 	for (l = node->attributes; l; l = l->next) {
 		KeyValuePair *kvp = (KeyValuePair *) l->data;
                 
@@ -272,6 +279,7 @@
         const gchar *ret_val = NULL;
 
         g_return_val_if_fail (node != NULL, NULL);
+        g_return_val_if_fail (name != NULL, NULL);
 
         for (l = node->attributes; l; l = l->next) {
                 KeyValuePair *kvp = (KeyValuePair *) l->data;
@@ -298,7 +306,10 @@
 lm_message_node_get_child (LmMessageNode *node, const gchar *child_name)
 {
 	LmMessageNode *l;
-	
+
+        g_return_val_if_fail (node != NULL, NULL);
+        g_return_val_if_fail (child_name != NULL, NULL);
+
 	for (l = node->children; l; l = l->next) {
 		if (strcmp (l->name, child_name) == 0) {
 			return l;
@@ -324,6 +335,9 @@
 {
         LmMessageNode *l;
         LmMessageNode *ret_val = NULL;
+
+        g_return_val_if_fail (node != NULL, NULL);
+        g_return_val_if_fail (child_name != NULL, NULL);
 
         for (l = node->children; l; l = l->next) {
                 if (strcmp (l->name, child_name) == 0) {
Index: loudmouth/lm-parser.c
===================================================================
RCS file: /cvs/gnome/loudmouth/loudmouth/lm-parser.c,v
retrieving revision 1.11
diff -u -r1.11 lm-parser.c
--- loudmouth/lm-parser.c	6 Jun 2006 12:39:19 -0000	1.11
+++ loudmouth/lm-parser.c	23 Aug 2006 12:32:25 -0000
@@ -21,6 +21,8 @@
 #include <config.h>
 #include <string.h>
 
+#include <glib.h>
+
 #include "lm-debug.h"
 #include "lm-internals.h"
 #include "lm-message-node.h"
@@ -211,6 +213,8 @@
 	       GDestroyNotify          notify)
 {
 	LmParser *parser;
+
+	g_return_val_if_fail (function != NULL, NULL);
 	
 	parser = g_new0 (LmParser, 1);
 	if (!parser) {
@@ -245,6 +249,7 @@
 lm_parser_parse (LmParser *parser, const gchar *string)
 {
 	g_return_if_fail (parser != NULL);
+	g_return_if_fail (string != NULL);
 	
         if (!parser->context) {
                 parser->context = g_markup_parse_context_new (parser->m_parser, 0,
@@ -261,6 +266,8 @@
 void
 lm_parser_free (LmParser *parser)
 {
+	g_return_if_fail (parser != NULL);
+
 	if (parser->notify) {
 		(* parser->notify) (parser->user_data);
 	}
Index: loudmouth/lm-sha.c
===================================================================
RCS file: /cvs/gnome/loudmouth/loudmouth/lm-sha.c,v
retrieving revision 1.6
diff -u -r1.6 lm-sha.c
--- loudmouth/lm-sha.c	3 Aug 2006 22:08:51 -0000	1.6
+++ loudmouth/lm-sha.c	23 Aug 2006 12:32:26 -0000
@@ -610,6 +610,8 @@
         gchar        *ch;
         guint          i;
         
+	g_return_val_if_fail (str != NULL, NULL);
+
         SHA1Init (&ctx);
         SHA1Update (&ctx, str, strlen (str));
         SHA1Final (&ctx, hash);
Index: loudmouth/lm-utils.c
===================================================================
RCS file: /cvs/gnome/loudmouth/loudmouth/lm-utils.c,v
retrieving revision 1.12
diff -u -r1.12 lm-utils.c
--- loudmouth/lm-utils.c	16 Jun 2006 09:21:33 -0000	1.12
+++ loudmouth/lm-utils.c	23 Aug 2006 12:32:26 -0000
@@ -166,13 +166,17 @@
 #else
 	return g_strdup(hostname);
 #endif
-}struct tm *
+}
+
+struct tm *
 lm_utils_get_localtime (const gchar *stamp)
 {
 	struct tm tm;
 	time_t    t;
 	gint      year, month;
 	
+	g_return_val_if_fail (stamp != NULL, NULL);
+
 	/* 20021209T23:51:30 */
 
 	sscanf (stamp, "%4d%2d%2dT%2d:%2d:%2d", 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to