changeset 11291:57fccea36e36

[gaim-migrate @ 13491] Gaim should pretty much never call g_assert. If any of these changes are in your code, you should try to take a look at the change and make sure Gaim won't crash after the function g_return_if_fails. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 18 Aug 2005 03:14:29 +0000
parents b284c703d398
children ef9280fdc511
files plugins/docklet/eggtrayicon.c src/dbus-server.c src/eventloop.c src/mime.c src/protocols/sametime/meanwhile/session.c src/protocols/sametime/meanwhile/srvc_aware.c src/protocols/sametime/meanwhile/srvc_conf.c
diffstat 7 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/docklet/eggtrayicon.c	Thu Aug 18 01:35:14 2005 +0000
+++ b/plugins/docklet/eggtrayicon.c	Thu Aug 18 03:14:29 2005 +0000
@@ -159,7 +159,7 @@
   gulong bytes_after;
   int error, result;
 
-  g_assert (icon->manager_window != None);
+  g_return_if_fail(icon->manager_window != None);
 
 #if GTK_CHECK_VERSION(2,1,0)
   xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
--- a/src/dbus-server.c	Thu Aug 18 01:35:14 2005 +0000
+++ b/src/dbus-server.c	Thu Aug 18 03:14:29 2005 +0000
@@ -77,8 +77,8 @@
 {
     static gint last_id = 0;
 
-    g_assert(map_node_id);
-    g_assert(g_hash_table_lookup(map_node_id, node) == NULL);
+    g_return_if_fail(map_node_id);
+    g_return_if_fail(g_hash_table_lookup(map_node_id, node) == NULL);
 	
     last_id++;
     g_hash_table_insert(map_node_id, node, GINT_TO_POINTER(last_id));
@@ -633,7 +633,7 @@
 	gpointer ptr = NULL;
 	if (gaim_value_is_outgoing(gaim_values[i])) {
 	    ptr = my_arg(gpointer);
-	    g_assert(ptr);
+	    g_return_if_fail(ptr);
 	}
 	
 	switch(gaim_values[i]->type) {
@@ -661,7 +661,7 @@
 	    dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &id);
 	    break;
 	default:		/* no conversion implemented */
-	    g_assert_not_reached();
+	    g_return_if_reached();
 	}
     }
 }
--- a/src/eventloop.c	Thu Aug 18 01:35:14 2005 +0000
+++ b/src/eventloop.c	Thu Aug 18 03:14:29 2005 +0000
@@ -67,7 +67,7 @@
 GaimEventLoopUiOps *
 gaim_eventloop_get_ui_ops(void)
 {
-	g_assert(eventloop_ui_ops != NULL);
+	g_return_val_if_fail(eventloop_ui_ops != NULL, NULL);
 
 	return eventloop_ui_ops;
 }
--- a/src/mime.c	Thu Aug 18 01:35:14 2005 +0000
+++ b/src/mime.c	Thu Aug 18 03:14:29 2005 +0000
@@ -66,8 +66,8 @@
 		       const char *key, const char *val) {
   char *k, *v;
 
-  g_assert(mf != NULL);
-  g_assert(mf->map != NULL);
+  g_return_if_fail(mf != NULL);
+  g_return_if_fail(mf->map != NULL);
 
   k = g_ascii_strdown(key, -1);
   v = g_strdup(val);
@@ -89,8 +89,8 @@
   char *kdown;
   const char *ret;
 
-  g_assert(mf != NULL);
-  g_assert(mf->map != NULL);
+  g_return_val_if_fail(mf != NULL, NULL);
+  g_return_val_if_fail(mf->map != NULL, NULL);
 
   kdown = g_ascii_strdown(key, -1);
   ret = g_hash_table_lookup(mf->map, kdown);
@@ -101,7 +101,7 @@
 
 
 static void fields_init(struct mime_fields *mf) {
-  g_assert(mf != NULL);
+  g_return_if_fail(mf != NULL);
 
   mf->map = g_hash_table_new_full(g_str_hash, g_str_equal,
 				  g_free, g_free);
@@ -190,7 +190,7 @@
 
 
 static void fields_write(struct mime_fields *mf, GString *str) {
-  g_assert(mf != NULL);
+  g_return_if_fail(mf != NULL);
 
   g_hash_table_foreach(mf->map, (GHFunc) field_write, str);
   g_string_append(str, "\r\n");
@@ -198,7 +198,7 @@
 
 
 static void fields_destroy(struct mime_fields *mf) {
-  g_assert(mf != NULL);
+  g_return_if_fail(mf != NULL);
 
   g_hash_table_destroy(mf->map);
   g_list_free(mf->keys);
@@ -297,7 +297,7 @@
 
 const char *gaim_mime_part_get_data(GaimMimePart *part) {
   g_return_val_if_fail(part != NULL, NULL);
-  g_assert(part->data != NULL);
+  g_return_val_if_fail(part->data != NULL, NULL);
 
   return part->data->str;
 }
@@ -311,7 +311,7 @@
   g_return_if_fail(data != NULL);
   g_return_if_fail(len != NULL);
 
-  g_assert(part->data != NULL);
+  g_return_if_fail(part->data != NULL);
 
   enc = gaim_mime_part_get_field(part, "content-transfer-encoding");
 
@@ -347,7 +347,7 @@
 
 gsize gaim_mime_part_get_length(GaimMimePart *part) {
   g_return_val_if_fail(part != NULL, 0);
-  g_assert(part->data != NULL);
+  g_return_val_if_fail(part->data != NULL, 0);
 
   return part->data->len;
 }
--- a/src/protocols/sametime/meanwhile/session.c	Thu Aug 18 01:35:14 2005 +0000
+++ b/src/protocols/sametime/meanwhile/session.c	Thu Aug 18 03:14:29 2005 +0000
@@ -548,7 +548,7 @@
   struct mwGetBuffer *b;
   struct mwMessage *msg;
 
-  g_assert(s != NULL);
+  g_return_if_fail(s != NULL);
   g_return_if_fail(buf != NULL);
 
   /* ignore zero-length messages */
--- a/src/protocols/sametime/meanwhile/srvc_aware.c	Thu Aug 18 01:35:14 2005 +0000
+++ b/src/protocols/sametime/meanwhile/srvc_aware.c	Thu Aug 18 03:14:29 2005 +0000
@@ -141,8 +141,8 @@
 
 static struct aware_entry *aware_find(struct mwServiceAware *srvc,
 				      struct mwAwareIdBlock *srch) {
-  g_assert(srvc != NULL);
-  g_assert(srvc->entries != NULL);
+  g_return_val_if_fail(srvc != NULL, NULL);
+  g_return_val_if_fail(srvc->entries != NULL, NULL);
   g_return_val_if_fail(srch != NULL, NULL);
   
   return g_hash_table_lookup(srvc->entries, srch);
--- a/src/protocols/sametime/meanwhile/srvc_conf.c	Thu Aug 18 01:35:14 2005 +0000
+++ b/src/protocols/sametime/meanwhile/srvc_conf.c	Thu Aug 18 03:14:29 2005 +0000
@@ -671,7 +671,7 @@
   g_return_val_if_fail(conf->channel == NULL, -1);
 
   session = mwService_getSession(MW_SERVICE(conf->service));
-  g_assert(session != NULL);
+  g_return_val_if_fail(session != NULL, -1);
 
   if(! conf->name) {
     char *user = mwSession_getProperty(session, mwSession_AUTH_USER_ID);