[evolution-data-server/gnome-3-16] Bug 471791 - Move away from g_asserts to g_ret*



commit d003102ab6336498162c0b28390d2b4449cd4eb8
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 17 12:00:24 2015 +0200

    Bug 471791 - Move away from g_asserts to g_ret*

 addressbook/backends/file/e-book-backend-file.c    |    4 +-
 .../backends/google/e-book-backend-google.c        |    2 +-
 addressbook/libebook-contacts/e-contact.c          |    2 +-
 .../e-source-backend-summary-setup.c               |    4 +-
 addressbook/libebook-contacts/e-vcard.c            |    2 +-
 addressbook/libegdbus/e-gdbus-book-view.c          |    6 ++--
 calendar/backends/caldav/e-cal-backend-caldav.c    |    8 ++--
 calendar/backends/file/e-cal-backend-file.c        |   20 +++++-----
 calendar/libedata-cal/e-cal-backend-sexp.c         |    2 +-
 calendar/libegdbus/e-gdbus-cal-view.c              |    6 ++--
 camel/camel-charset-map.c                          |    2 +-
 camel/camel-debug.c                                |    4 +-
 camel/camel-filter-driver.c                        |    6 +---
 camel/camel-folder-search.c                        |   11 ++++--
 camel/camel-folder-summary.c                       |    2 +-
 camel/camel-internet-address.c                     |   21 ++++++-----
 camel/camel-mime-filter-basic.c                    |   20 +++++-----
 camel/camel-mime-filter-enriched.c                 |    2 +-
 camel/camel-mime-filter-yenc.c                     |   10 +++---
 camel/camel-mime-message.c                         |   24 ++++++-------
 camel/camel-mime-parser.c                          |    4 +-
 camel/camel-mime-part-utils.c                      |    4 +-
 camel/camel-mime-utils.c                           |    2 +-
 camel/camel-movemail.c                             |    2 +-
 camel/camel-msgport.c                              |    2 +-
 camel/camel-multipart-signed.c                     |    2 +-
 camel/camel-multipart.c                            |    2 +-
 camel/camel-nntp-address.c                         |    6 ++--
 camel/camel-partition-table.c                      |    4 --
 camel/camel-sexp.c                                 |    8 ++--
 camel/camel-store.c                                |    4 +-
 camel/camel-text-index.c                           |    8 ++--
 camel/camel-url-scanner.c                          |    4 +-
 camel/camel-vtrash-folder.c                        |    2 +-
 camel/providers/imapx/camel-imapx-command.c        |    2 +-
 camel/providers/imapx/camel-imapx-server.c         |    2 +-
 camel/providers/local/camel-local-folder.c         |    4 +-
 camel/providers/local/camel-mbox-folder.c          |    4 +-
 camel/providers/local/camel-mbox-summary.c         |    2 +-
 camel/providers/local/camel-mh-summary.c           |    2 +-
 camel/providers/local/camel-spool-summary.c        |    2 +-
 camel/providers/nntp/camel-nntp-store-summary.c    |    2 +-
 camel/providers/pop3/camel-pop3-folder.c           |    4 +-
 camel/tests/lib/camel-test.c                       |    2 +-
 camel/tests/mime-filter/test-charset.c             |    1 -
 examples/cursor/cursor-data.c                      |    4 +-
 libedataserver/e-debug-log.c                       |   38 ++++++++++----------
 libedataserver/e-gdbus-templates.c                 |   20 +++++-----
 libedataserver/e-sexp.c                            |    8 ++--
 .../evolution-source-registry-migrate-sources.c    |    5 ++-
 tests/book-migration/setup-migration-test.c        |    2 +-
 51 files changed, 158 insertions(+), 158 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index ed8dfd5..28eaf63 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -295,7 +295,7 @@ safe_name_for_photo (EBookBackendFile *bf,
        gchar         *suffix = NULL;
        gint           i = 0;
 
-       g_assert (photo->type == E_CONTACT_PHOTO_TYPE_INLINED);
+       g_return_val_if_fail (photo->type == E_CONTACT_PHOTO_TYPE_INLINED, NULL);
 
        /* Get a suitable filename extension */
        if (photo->data.inlined.mime_type != NULL &&
@@ -550,7 +550,7 @@ maybe_transform_vcard_field_for_photo (EBookBackendFile *bf,
                         * logic to the file-system.
                         */
                        filename = g_filename_from_uri (photo->data.uri, NULL, NULL);
-                       g_assert (filename); /* we already checked this with 'is_backend_owned_uri ()' */
+                       g_return_val_if_fail (filename, STATUS_NORMAL); /* we already checked this with 
'is_backend_owned_uri ()' */
 
                        new_filename = hard_link_photo (bf, contact, field, filename, error);
 
diff --git a/addressbook/backends/google/e-book-backend-google.c 
b/addressbook/backends/google/e-book-backend-google.c
index 13a1eab..d6b5fae 100644
--- a/addressbook/backends/google/e-book-backend-google.c
+++ b/addressbook/backends/google/e-book-backend-google.c
@@ -795,7 +795,7 @@ get_new_contacts (EBookBackend *backend)
 
        /* Sort out update times */
        last_updated = cache_get_last_update (backend);
-       g_assert (last_updated == NULL || g_time_val_from_iso8601 (last_updated, &updated) == TRUE);
+       g_return_if_fail (last_updated == NULL || g_time_val_from_iso8601 (last_updated, &updated) == TRUE);
        g_free (last_updated);
 
        /* Prevent the cache writing each change to disk individually (thawed in get_new_contacts_cb()) */
diff --git a/addressbook/libebook-contacts/e-contact.c b/addressbook/libebook-contacts/e-contact.c
index 4817d12..cfc81ba 100644
--- a/addressbook/libebook-contacts/e-contact.c
+++ b/addressbook/libebook-contacts/e-contact.c
@@ -371,7 +371,7 @@ e_contact_class_init (EContactClass *class)
                GParamFlags flags;
 
                /* Verify the table is correctly ordered */
-               g_assert (ii == field_info[ii].field_id);
+               g_return_if_fail (ii == field_info[ii].field_id);
 
                flags = G_PARAM_READABLE |
                        G_PARAM_STATIC_NICK |
diff --git a/addressbook/libebook-contacts/e-source-backend-summary-setup.c 
b/addressbook/libebook-contacts/e-source-backend-summary-setup.c
index e4cd0f4..87da6ed 100644
--- a/addressbook/libebook-contacts/e-source-backend-summary-setup.c
+++ b/addressbook/libebook-contacts/e-source-backend-summary-setup.c
@@ -85,7 +85,7 @@ source_backend_summary_setup_dup_literal_fields (ESourceBackendSummarySetup *ext
                        duplicate = g_strdup (extension->priv->indexed_fields);
                        break;
                default:
-                       g_assert_not_reached ();
+                       g_return_val_if_reached (NULL);
                        break;
        }
 
@@ -112,7 +112,7 @@ source_backend_summary_setup_set_literal_fields (ESourceBackendSummarySetup *ext
                        property_name = "indexed-fields";
                        break;
                default:
-                       g_assert_not_reached ();
+                       g_return_if_reached ();
                        break;
        }
 
diff --git a/addressbook/libebook-contacts/e-vcard.c b/addressbook/libebook-contacts/e-vcard.c
index 5a74eea..c15faa0 100644
--- a/addressbook/libebook-contacts/e-vcard.c
+++ b/addressbook/libebook-contacts/e-vcard.c
@@ -728,7 +728,7 @@ make_valid_utf8 (const gchar *name)
 
        g_string_append (string, remainder);
 
-       g_assert (g_utf8_validate (string->str, -1, NULL));
+       g_return_val_if_fail (g_utf8_validate (string->str, -1, NULL), g_string_free (string, TRUE));
 
        return g_string_free (string, FALSE);
 }
diff --git a/addressbook/libegdbus/e-gdbus-book-view.c b/addressbook/libegdbus/e-gdbus-book-view.c
index e95efc2..992758c 100644
--- a/addressbook/libegdbus/e-gdbus-book-view.c
+++ b/addressbook/libegdbus/e-gdbus-book-view.c
@@ -461,7 +461,7 @@ emit_notifications_in_idle (gpointer user_data)
        path = g_object_get_data (object, "gdbus-codegen-path");
        connection = g_object_get_data (object, "gdbus-codegen-connection");
        pvc = g_object_get_data (object, "gdbus-codegen-pvc");
-       g_assert (notification_queue != NULL && path != NULL && connection != NULL && pvc != NULL);
+       g_return_val_if_fail (notification_queue != NULL && path != NULL && connection != NULL && pvc != 
NULL, FALSE);
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
        invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
@@ -678,7 +678,7 @@ e_gdbus_book_view_proxy_new_finish (GAsyncResult *result,
        GObject *object;
        GObject *source_object;
        source_object = g_async_result_get_source_object (result);
-       g_assert (source_object != NULL);
+       g_return_val_if_fail (source_object != NULL, NULL);
        object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), result, error);
        g_object_unref (source_object);
        if (object != NULL)
@@ -780,7 +780,7 @@ e_gdbus_book_view_proxy_new_for_bus_finish (GAsyncResult *result,
        GObject *object;
        GObject *source_object;
        source_object = g_async_result_get_source_object (result);
-       g_assert (source_object != NULL);
+       g_return_val_if_fail (source_object != NULL, NULL);
        object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), result, error);
        g_object_unref (source_object);
        if (object != NULL)
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index dcf88bc..bf25551 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -1778,7 +1778,7 @@ caldav_server_get_object (ECalBackendCalDAV *cbdav,
        const gchar               *hdr;
        gchar                     *uri;
 
-       g_assert (object != NULL && object->href != NULL);
+       g_return_val_if_fail (object != NULL && object->href != NULL, FALSE);
 
        uri = caldav_generate_uri (cbdav, object->href);
        message = soup_message_new (SOUP_METHOD_GET, uri);
@@ -1925,7 +1925,7 @@ caldav_server_put_object (ECalBackendCalDAV *cbdav,
 
        hdr = NULL;
 
-       g_assert (object != NULL && object->cdata != NULL);
+       g_return_val_if_fail (object != NULL && object->cdata != NULL, FALSE);
 
        uri = caldav_generate_uri (cbdav, object->href);
        message = soup_message_new (SOUP_METHOD_PUT, uri);
@@ -2072,7 +2072,7 @@ caldav_server_delete_object (ECalBackendCalDAV *cbdav,
        SoupMessage              *message;
        gchar                     *uri;
 
-       g_assert (object != NULL && object->href != NULL);
+       g_return_if_fail (object != NULL && object->href != NULL);
 
        uri = caldav_generate_uri (cbdav, object->href);
        message = soup_message_new (SOUP_METHOD_DELETE, uri);
@@ -3832,7 +3832,7 @@ pack_cobj (ECalBackendCalDAV *cbdav,
        objstr = icalcomponent_as_ical_string_r (calcomp);
        icalcomponent_free (calcomp);
 
-       g_assert (objstr);
+       g_return_val_if_fail (objstr != NULL, NULL);
 
        return objstr;
 
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index 6e87271..6d0c287 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -156,8 +156,8 @@ save_file_when_idle (gpointer user_data)
        gboolean writable;
 
        priv = cbfile->priv;
-       g_assert (priv->path != NULL);
-       g_assert (priv->icalcomp != NULL);
+       g_return_val_if_fail (priv->path != NULL, FALSE);
+       g_return_val_if_fail (priv->icalcomp != NULL, FALSE);
 
        writable = e_cal_backend_get_writable (E_CAL_BACKEND (cbfile));
 
@@ -749,7 +749,7 @@ add_component (ECalBackendFile *cbfile,
                icalcomponent *icalcomp;
 
                icalcomp = e_cal_component_get_icalcomponent (comp);
-               g_assert (icalcomp != NULL);
+               g_return_if_fail (icalcomp != NULL);
 
                icalcomponent_add_component (priv->icalcomp, icalcomp);
        }
@@ -771,7 +771,7 @@ remove_recurrence_cb (gpointer key,
 
        /* remove the recurrence from the top-level calendar */
        icalcomp = e_cal_component_get_icalcomponent (comp);
-       g_assert (icalcomp != NULL);
+       g_return_val_if_fail (icalcomp != NULL, FALSE);
 
        if (!remove_component_from_intervaltree (cbfile, comp)) {
                g_message (G_STRLOC " Could not remove component from interval tree!");
@@ -803,13 +803,13 @@ remove_component (ECalBackendFile *cbfile,
        /* Remove the icalcomp from the toplevel */
        if (obj_data->full_object) {
                icalcomp = e_cal_component_get_icalcomponent (obj_data->full_object);
-               g_assert (icalcomp != NULL);
+               g_return_if_fail (icalcomp != NULL);
 
                icalcomponent_remove_component (priv->icalcomp, icalcomp);
 
                /* Remove it from our mapping */
                l = g_list_find (priv->comp, obj_data->full_object);
-               g_assert (l != NULL);
+               g_return_if_fail (l != NULL);
                priv->comp = g_list_delete_link (priv->comp, l);
 
                if (!remove_component_from_intervaltree (cbfile, obj_data->full_object)) {
@@ -833,8 +833,8 @@ scan_vcalendar (ECalBackendFile *cbfile)
        icalcompiter iter;
 
        priv = cbfile->priv;
-       g_assert (priv->icalcomp != NULL);
-       g_assert (priv->comp_uid_hash != NULL);
+       g_return_if_fail (priv->icalcomp != NULL);
+       g_return_if_fail (priv->comp_uid_hash != NULL);
 
        for (iter = icalcomponent_begin_component (priv->icalcomp, ICAL_ANY_COMPONENT);
             icalcompiter_deref (&iter) != NULL;
@@ -1479,7 +1479,7 @@ e_cal_backend_file_get_object (ECalBackendSync *backend,
        }
 
        g_return_if_fail (uid != NULL);
-       g_assert (priv->comp_uid_hash != NULL);
+       g_return_if_fail (priv->comp_uid_hash != NULL);
 
        g_rec_mutex_lock (&priv->idle_save_rmutex);
 
@@ -1791,7 +1791,7 @@ e_cal_backend_file_get_attachment_uris (ECalBackendSync *backend,
        cbfile = E_CAL_BACKEND_FILE (backend);
        priv = cbfile->priv;
 
-       g_assert (priv->comp_uid_hash != NULL);
+       g_return_if_fail (priv->comp_uid_hash != NULL);
 
        g_rec_mutex_lock (&priv->idle_save_rmutex);
 
diff --git a/calendar/libedata-cal/e-cal-backend-sexp.c b/calendar/libedata-cal/e-cal-backend-sexp.c
index ecd1b65..5f038eb 100644
--- a/calendar/libedata-cal/e-cal-backend-sexp.c
+++ b/calendar/libedata-cal/e-cal-backend-sexp.c
@@ -376,7 +376,7 @@ matches_text_list (GSList *text_list,
                ECalComponentText *text;
 
                text = l->data;
-               g_assert (text->value != NULL);
+               g_return_val_if_fail (text->value != NULL, FALSE);
 
                if (e_util_utf8_strstrcasedecomp (text->value, str) != NULL) {
                        matches = TRUE;
diff --git a/calendar/libegdbus/e-gdbus-cal-view.c b/calendar/libegdbus/e-gdbus-cal-view.c
index 5f62838..ce9acc3 100644
--- a/calendar/libegdbus/e-gdbus-cal-view.c
+++ b/calendar/libegdbus/e-gdbus-cal-view.c
@@ -461,7 +461,7 @@ emit_notifications_in_idle (gpointer user_data)
        path = g_object_get_data (object, "gdbus-codegen-path");
        connection = g_object_get_data (object, "gdbus-codegen-connection");
        pvc = g_object_get_data (object, "gdbus-codegen-pvc");
-       g_assert (notification_queue != NULL && path != NULL && connection != NULL && pvc != NULL);
+       g_return_val_if_fail (notification_queue != NULL && path != NULL && connection != NULL && pvc != 
NULL, FALSE);
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
        invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
@@ -678,7 +678,7 @@ e_gdbus_cal_view_proxy_new_finish (GAsyncResult *result,
        GObject *object;
        GObject *source_object;
        source_object = g_async_result_get_source_object (result);
-       g_assert (source_object != NULL);
+       g_return_val_if_fail (source_object != NULL, NULL);
        object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), result, error);
        g_object_unref (source_object);
        if (object != NULL)
@@ -780,7 +780,7 @@ e_gdbus_cal_view_proxy_new_for_bus_finish (GAsyncResult *result,
        GObject *object;
        GObject *source_object;
        source_object = g_async_result_get_source_object (result);
-       g_assert (source_object != NULL);
+       g_return_val_if_fail (source_object != NULL, NULL);
        object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), result, error);
        g_object_unref (source_object);
        if (object != NULL)
diff --git a/camel/camel-charset-map.c b/camel/camel-charset-map.c
index 9159d42..8fa7ec1 100644
--- a/camel/camel-charset-map.c
+++ b/camel/camel-charset-map.c
@@ -137,7 +137,7 @@ gint main (gint argc, gchar **argv)
 
        /* dont count the terminator */
        bytes = (G_N_ELEMENTS (tables) + 7 - 1) / 8;
-       g_assert (bytes <= 4);
+       g_return_val_if_fail (bytes <= 4, -1);
 
        for (i = 0; i < 128; i++)
                in[i] = i + 128;
diff --git a/camel/camel-debug.c b/camel/camel-debug.c
index 8c75817..0fe2b05 100644
--- a/camel/camel-debug.c
+++ b/camel/camel-debug.c
@@ -229,8 +229,8 @@ camel_debug_hwatch (gint wp,
 {
      guint32 control, rw;
 
-     g_assert (wp <= DR_LASTADDR);
-     g_assert (sizeof (addr) == 4);
+     g_return_if_fail (wp <= DR_LASTADDR);
+     g_return_if_fail (sizeof (addr) == 4);
 
      get_dr (7, control);
      /* set watch mode + size */
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index c82562b..ce98f64 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -1668,11 +1668,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver,
        GList *list, *link;
        gint result;
 
-       /* FIXME: make me into a g_return_if_fail/g_assert or whatever... */
-       if (message == NULL && (source == NULL || uid == NULL)) {
-               g_warning ("there is no way to fetch the message using the information provided...");
-               return -1;
-       }
+       g_return_val_if_fail (message != NULL || (source != NULL && uid != NULL), -1);
 
        if (info == NULL) {
                struct _camel_header_raw *h;
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index 1c43999..33d53a8 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -929,7 +929,6 @@ folder_search_match_all (CamelSExp *sexp,
        if (search->summary == NULL) {
                /* TODO: make it work - e.g. use the folder and so forth for a slower search */
                g_warning ("No summary supplied, match-all doesn't work with no summary");
-               g_assert (0);
                return r;
        }
 
@@ -1936,7 +1935,10 @@ camel_folder_search_count (CamelFolderSearch *search,
        if (!expr || !*expr)
                expr = "(match-all)";
 
-       g_assert (search->folder);
+       if (!search->folder) {
+               g_warn_if_reached ();
+               goto fail;
+       }
 
        p->cancellable = cancellable;
        p->error = error;
@@ -2090,7 +2092,10 @@ camel_folder_search_search (CamelFolderSearch *search,
        if (!expr || !*expr)
                expr = "(match-all)";
 
-       g_assert (search->folder);
+       if (!search->folder) {
+               g_warn_if_reached ();
+               goto fail;
+       }
 
        p->cancellable = cancellable;
        p->error = error;
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 79d2b2e..4c3be3f 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -4023,7 +4023,7 @@ summary_build_content_info_message (CamelFolderSummary *summary,
 
                for (i = 0; i < parts; i++) {
                        CamelMimePart *part = camel_multipart_get_part (CAMEL_MULTIPART (containee), i);
-                       g_assert (part);
+                       g_return_val_if_fail (part, info);
                        child = summary_build_content_info_message (summary, msginfo, part);
                        if (child) {
                                child->parent = info;
diff --git a/camel/camel-internet-address.c b/camel/camel-internet-address.c
index c89a4d4..9516fcc 100644
--- a/camel/camel-internet-address.c
+++ b/camel/camel-internet-address.c
@@ -213,7 +213,7 @@ internet_address_cat (CamelAddress *dest,
 {
        gint i;
 
-       g_assert (CAMEL_IS_INTERNET_ADDRESS (source));
+       g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (source), -1);
 
        for (i = 0; i < source->addresses->len; i++) {
                struct _address *addr = g_ptr_array_index (source->addresses, i);
@@ -273,7 +273,7 @@ camel_internet_address_add (CamelInternetAddress *addr,
        struct _address *new;
        gint index;
 
-       g_assert (CAMEL_IS_INTERNET_ADDRESS (addr));
+       g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (addr), -1);
 
        new = g_malloc (sizeof (*new));
        new->name = g_strdup (name);
@@ -303,7 +303,7 @@ camel_internet_address_get (CamelInternetAddress *addr,
 {
        struct _address *a;
 
-       g_assert (CAMEL_IS_INTERNET_ADDRESS (addr));
+       g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (addr), FALSE);
 
        if (index < 0 || index >= ((CamelAddress *) addr)->addresses->len)
                return FALSE;
@@ -335,7 +335,7 @@ camel_internet_address_find_name (CamelInternetAddress *addr,
        struct _address *a;
        gint i, len;
 
-       g_assert (CAMEL_IS_INTERNET_ADDRESS (addr));
+       g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (addr), -1);
 
        len = ((CamelAddress *) addr)->addresses->len;
        for (i = 0; i < len; i++) {
@@ -432,7 +432,7 @@ camel_internet_address_find_address (CamelInternetAddress *addr,
        struct _address *a;
        gint i, len;
 
-       g_assert (CAMEL_IS_INTERNET_ADDRESS (addr));
+       g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (addr), -1);
 
        len = ((CamelAddress *) addr)->addresses->len;
        for (i = 0; i < len; i++) {
@@ -503,12 +503,15 @@ camel_internet_address_encode_address (gint *inlen,
                                        const gchar *real,
                                        const gchar *addr)
 {
-       gchar *name = camel_header_encode_phrase ((const guchar *) real);
+       gchar *name;
        gchar *ret = NULL;
        gint len = 0;
-       GString *out = g_string_new ("");
+       GString *out;
 
-       g_assert (addr);
+       g_return_val_if_fail (addr, NULL);
+
+       name = camel_header_encode_phrase ((const guchar *) real);
+       out = g_string_new ("");
 
        if (inlen != NULL)
                len = *inlen;
@@ -576,7 +579,7 @@ camel_internet_address_format_address (const gchar *name,
 {
        gchar *ret = NULL;
 
-       g_assert (addr);
+       g_return_val_if_fail (addr, NULL);
 
        if (name && name[0]) {
                const gchar *p = name;
diff --git a/camel/camel-mime-filter-basic.c b/camel/camel-mime-filter-basic.c
index 26656ae..6f7f000 100644
--- a/camel/camel-mime-filter-basic.c
+++ b/camel/camel-mime-filter-basic.c
@@ -61,7 +61,7 @@ mime_filter_basic_filter (CamelMimeFilter *mime_filter,
                        mime_filter->outbuf,
                        &priv->state,
                        &priv->save);
-               g_assert (newlen <= len * 2 + 6);
+               g_return_if_fail (newlen <= len * 2 + 6);
                break;
        case CAMEL_MIME_FILTER_BASIC_QP_ENC:
                /* *4 is overly conservative, but will do */
@@ -72,7 +72,7 @@ mime_filter_basic_filter (CamelMimeFilter *mime_filter,
                        (guchar *) mime_filter->outbuf,
                        &priv->state,
                        (gint *) &priv->save);
-               g_assert (newlen <= len * 4 + 4);
+               g_return_if_fail (newlen <= len * 4 + 4);
                break;
        case CAMEL_MIME_FILTER_BASIC_UU_ENC:
                /* won't go to more than 2 * (x + 2) + 62 */
@@ -84,7 +84,7 @@ mime_filter_basic_filter (CamelMimeFilter *mime_filter,
                        priv->uubuf,
                        &priv->state,
                        (guint32 *) &priv->save);
-               g_assert (newlen <= (len + 2) * 2 + 62);
+               g_return_if_fail (newlen <= (len + 2) * 2 + 62);
                break;
        case CAMEL_MIME_FILTER_BASIC_BASE64_DEC:
                /* output can't possibly exceed the input size */
@@ -94,7 +94,7 @@ mime_filter_basic_filter (CamelMimeFilter *mime_filter,
                        (guchar *) mime_filter->outbuf,
                        &priv->state,
                        (guint *) &priv->save);
-               g_assert (newlen <= len + 3);
+               g_return_if_fail (newlen <= len + 3);
                break;
        case CAMEL_MIME_FILTER_BASIC_QP_DEC:
                /* output can't possibly exceed the input size */
@@ -104,7 +104,7 @@ mime_filter_basic_filter (CamelMimeFilter *mime_filter,
                        (guchar *) mime_filter->outbuf,
                        &priv->state,
                        (gint *) &priv->save);
-               g_assert (newlen <= len + 2);
+               g_return_if_fail (newlen <= len + 2);
                break;
        case CAMEL_MIME_FILTER_BASIC_UU_DEC:
                if (!(priv->state & CAMEL_UUDECODE_STATE_BEGIN)) {
@@ -203,7 +203,7 @@ mime_filter_basic_complete (CamelMimeFilter *mime_filter,
                        mime_filter->outbuf,
                        &priv->state,
                        &priv->save);
-               g_assert (newlen <= len * 2 + 6);
+               g_return_if_fail (newlen <= len * 2 + 6);
                break;
        case CAMEL_MIME_FILTER_BASIC_QP_ENC:
                /* *4 is definetly more than needed ... */
@@ -214,7 +214,7 @@ mime_filter_basic_complete (CamelMimeFilter *mime_filter,
                        (guchar *) mime_filter->outbuf,
                        &priv->state,
                        &priv->save);
-               g_assert (newlen <= len * 4 + 4);
+               g_return_if_fail (newlen <= len * 4 + 4);
                break;
        case CAMEL_MIME_FILTER_BASIC_UU_ENC:
                /* won't go to more than 2 * (x + 2) + 62 */
@@ -226,7 +226,7 @@ mime_filter_basic_complete (CamelMimeFilter *mime_filter,
                        priv->uubuf,
                        &priv->state,
                        (guint32 *) &priv->save);
-               g_assert (newlen <= (len + 2) * 2 + 62);
+               g_return_if_fail (newlen <= (len + 2) * 2 + 62);
                break;
        case CAMEL_MIME_FILTER_BASIC_BASE64_DEC:
                /* output can't possibly exceed the input size */
@@ -236,7 +236,7 @@ mime_filter_basic_complete (CamelMimeFilter *mime_filter,
                        (guchar *) mime_filter->outbuf,
                        &priv->state,
                        (guint *) &priv->save);
-               g_assert (newlen <= len);
+               g_return_if_fail (newlen <= len);
                break;
        case CAMEL_MIME_FILTER_BASIC_QP_DEC:
                /* output can't possibly exceed the input size,
@@ -247,7 +247,7 @@ mime_filter_basic_complete (CamelMimeFilter *mime_filter,
                        (guchar *) mime_filter->outbuf,
                        &priv->state,
                        (gint *) &priv->save);
-               g_assert (newlen <= len + 2);
+               g_return_if_fail (newlen <= len + 2);
                break;
        case CAMEL_MIME_FILTER_BASIC_UU_DEC:
                if ((priv->state & CAMEL_UUDECODE_STATE_BEGIN) && !(priv->state & CAMEL_UUDECODE_STATE_END)) {
diff --git a/camel/camel-mime-filter-enriched.c b/camel/camel-mime-filter-enriched.c
index bb04d26..a8247b8 100644
--- a/camel/camel-mime-filter-enriched.c
+++ b/camel/camel-mime-filter-enriched.c
@@ -209,7 +209,7 @@ param_parse (const gchar *enriched,
                        return enriched_tags[i].parse_param (inptr, inlen);
        }
 
-       g_assert_not_reached ();
+       g_warn_if_reached ();
 
        return NULL;
 }
diff --git a/camel/camel-mime-filter-yenc.c b/camel/camel-mime-filter-yenc.c
index e303884..0f18f0f 100644
--- a/camel/camel-mime-filter-yenc.c
+++ b/camel/camel-mime-filter-yenc.c
@@ -66,7 +66,7 @@ mime_filter_yenc_filter (CamelMimeFilter *mime_filter,
                                (const guchar *) in, len,
                                (guchar *) mime_filter->outbuf, &priv->state,
                                &priv->pcrc, &priv->crc);
-                       g_assert (newlen <= (len + 2) * 2 + 62);
+                       g_return_if_fail (newlen <= (len + 2) * 2 + 62);
                        break;
                case CAMEL_MIME_FILTER_YENC_DIRECTION_DECODE:
                        if (!(priv->state & CAMEL_MIME_YDECODE_STATE_DECODE)) {
@@ -140,7 +140,7 @@ mime_filter_yenc_filter (CamelMimeFilter *mime_filter,
                                        (const guchar *) in, len,
                                        (guchar *) mime_filter->outbuf,
                                        &priv->state, &priv->pcrc, &priv->crc);
-                               g_assert (newlen <= len + 3);
+                               g_return_if_fail (newlen <= len + 3);
                        } else {
                                newlen = 0;
                        }
@@ -175,7 +175,7 @@ mime_filter_yenc_complete (CamelMimeFilter *mime_filter,
                                (const guchar *) in, len,
                                (guchar *) mime_filter->outbuf,
                                &priv->state, &priv->pcrc, &priv->crc);
-                       g_assert (newlen <= (len + 2) * 2 + 62);
+                       g_return_if_fail (newlen <= (len + 2) * 2 + 62);
                        break;
                case CAMEL_MIME_FILTER_YENC_DIRECTION_DECODE:
                        if ((priv->state & CAMEL_MIME_YDECODE_STATE_DECODE) &&
@@ -188,7 +188,7 @@ mime_filter_yenc_complete (CamelMimeFilter *mime_filter,
                                        (const guchar *) in, len,
                                        (guchar *) mime_filter->outbuf,
                                        &priv->state, &priv->pcrc, &priv->crc);
-                               g_assert (newlen <= len + 3);
+                               g_return_if_fail (newlen <= len + 3);
                        } else {
                                newlen = 0;
                        }
@@ -271,7 +271,7 @@ camel_mime_filter_yenc_new (CamelMimeFilterYencDirection direction)
                        priv->state = CAMEL_MIME_YDECODE_STATE_INIT;
                        break;
                default:
-                       g_assert_not_reached ();
+                       g_warn_if_reached ();
        }
 
        return filter;
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index a633210..cdd85ae 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -183,8 +183,6 @@ mime_message_ensure_required_headers (CamelMimeMessage *message)
        CamelMedium *medium = CAMEL_MEDIUM (message);
 
        if (message->from == NULL) {
-               /* FIXME: should we just abort?  Should we make one up? */
-               g_warning ("No from set for message");
                camel_medium_set_header (medium, "From", "");
        }
        if (!camel_medium_get_header (medium, "Date"))
@@ -448,7 +446,7 @@ camel_mime_message_set_date (CamelMimeMessage *message,
 {
        gchar *datestr;
 
-       g_assert (message);
+       g_return_if_fail (message);
 
        if (date == CAMEL_MESSAGE_DATE_CURRENT) {
                struct tm local;
@@ -529,7 +527,7 @@ camel_mime_message_set_message_id (CamelMimeMessage *mime_message,
 {
        gchar *id;
 
-       g_assert (mime_message);
+       g_return_if_fail (mime_message);
 
        g_free (mime_message->message_id);
 
@@ -568,7 +566,7 @@ camel_mime_message_set_message_id (CamelMimeMessage *mime_message,
 const gchar *
 camel_mime_message_get_message_id (CamelMimeMessage *mime_message)
 {
-       g_assert (mime_message);
+       g_return_val_if_fail (mime_message, NULL);
 
        return mime_message->message_id;
 }
@@ -588,7 +586,7 @@ camel_mime_message_set_reply_to (CamelMimeMessage *msg,
 {
        gchar *addr;
 
-       g_assert (msg);
+       g_return_if_fail (msg);
 
        if (msg->reply_to) {
                g_object_unref (msg->reply_to);
@@ -617,7 +615,7 @@ camel_mime_message_set_reply_to (CamelMimeMessage *msg,
 CamelInternetAddress *
 camel_mime_message_get_reply_to (CamelMimeMessage *mime_message)
 {
-       g_assert (mime_message);
+       g_return_val_if_fail (mime_message, NULL);
 
        /* TODO: ref for threading? */
 
@@ -639,7 +637,7 @@ camel_mime_message_set_subject (CamelMimeMessage *message,
 {
        gchar *text;
 
-       g_assert (message);
+       g_return_if_fail (message);
 
        g_free (message->subject);
 
@@ -666,7 +664,7 @@ camel_mime_message_set_subject (CamelMimeMessage *message,
 const gchar *
 camel_mime_message_get_subject (CamelMimeMessage *mime_message)
 {
-       g_assert (mime_message);
+       g_return_val_if_fail (mime_message, NULL);
 
        return mime_message->subject;
 }
@@ -690,7 +688,7 @@ camel_mime_message_set_from (CamelMimeMessage *msg,
 {
        gchar *addr;
 
-       g_assert (msg);
+       g_return_if_fail (msg);
 
        if (msg->from) {
                g_object_unref (msg->from);
@@ -719,7 +717,7 @@ camel_mime_message_set_from (CamelMimeMessage *msg,
 CamelInternetAddress *
 camel_mime_message_get_from (CamelMimeMessage *mime_message)
 {
-       g_assert (mime_message);
+       g_return_val_if_fail (mime_message, NULL);
 
        /* TODO: we should really ref this for multi-threading to work */
 
@@ -744,7 +742,7 @@ camel_mime_message_set_recipients (CamelMimeMessage *mime_message,
        gchar *text;
        CamelInternetAddress *addr;
 
-       g_assert (mime_message);
+       g_return_if_fail (mime_message);
 
        addr = g_hash_table_lookup (mime_message->recipients, type);
        if (addr == NULL) {
@@ -780,7 +778,7 @@ CamelInternetAddress *
 camel_mime_message_get_recipients (CamelMimeMessage *mime_message,
                                    const gchar *type)
 {
-       g_assert (mime_message);
+       g_return_val_if_fail (mime_message, NULL);
 
        return g_hash_table_lookup (mime_message->recipients, type);
 }
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index 5a4fa2c..a0287b4 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -974,7 +974,7 @@ folder_read (struct _header_scan_state *s)
                s->ioerrno = errno ? errno : EIO;
        }
 
-       g_assert (s->inptr <= s->inend);
+       g_return_val_if_fail (s->inptr <= s->inend, 0);
 #ifdef PURIFY
        inend_id = purify_watch (&s->inend);
        inbuffer_id = purify_watch_n (s->inend + 1, SCAN_HEAD - 1, "rw");
@@ -1291,7 +1291,7 @@ folder_scan_header (struct _header_scan_state *s,
                                while ((*inptr++) != '\n')
                                        ;
 
-                               g_assert (inptr <= s->inend + 1);
+                               g_return_val_if_fail (inptr <= s->inend + 1, NULL);
 
                                /* check for sentinal or real end of line */
                                if (inptr > inend) {
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index 44d4a82..8959a25 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -175,8 +175,8 @@ camel_mime_message_build_preview (CamelMimePart *msg,
                gint i, nparts;
                CamelMultipart *mp = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) msg);
 
-               if (!CAMEL_IS_MULTIPART (mp))
-                       g_assert (0);
+               g_warn_if_fail (CAMEL_IS_MULTIPART (mp));
+
                nparts = camel_multipart_get_number (mp);
                for (i = 0; i < nparts && !got_plain; i++) {
                        CamelMimePart *part = camel_multipart_get_part (mp, i);
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 0a98411..6fae183 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -4824,7 +4824,7 @@ mailing_list_init (gpointer param)
                }
        }
 
-       g_assert (failed == 0);
+       g_warn_if_fail (failed == 0);
 
        return NULL;
 }
diff --git a/camel/camel-movemail.c b/camel/camel-movemail.c
index 6067f4e..9e4d067 100644
--- a/camel/camel-movemail.c
+++ b/camel/camel-movemail.c
@@ -509,7 +509,7 @@ camel_movemail_solaris (gint oldsfd,
        ffrom = camel_mime_filter_from_new ();
 
        while (camel_mime_parser_step (mp, &buffer, &len) == CAMEL_MIME_PARSER_STATE_FROM) {
-               g_assert (camel_mime_parser_from_line (mp));
+               g_return_val_if_fail (camel_mime_parser_from_line (mp), -1);
                from = g_strdup (camel_mime_parser_from_line (mp));
                if (camel_mime_parser_step (mp, &buffer, &len) != CAMEL_MIME_PARSER_STATE_FROM_END) {
                        const gchar *cl;
diff --git a/camel/camel-msgport.c b/camel/camel-msgport.c
index 58b3484..210315d 100644
--- a/camel/camel-msgport.c
+++ b/camel/camel-msgport.c
@@ -391,7 +391,7 @@ camel_msgport_pop (CamelMsgPort *msgport)
 
        msg = g_async_queue_pop_unlocked (msgport->queue);
 
-       g_assert (msg != NULL);
+       g_return_val_if_fail (msg != NULL, NULL);
 
        if (msg->flags & MSG_FLAG_SYNC_WITH_PIPE)
                msgport_sync_with_pipe (msgport->pipe[0]);
diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c
index afbe7a7..1fa5091 100644
--- a/camel/camel-multipart-signed.c
+++ b/camel/camel-multipart-signed.c
@@ -674,7 +674,7 @@ multipart_signed_construct_from_parser (CamelMultipart *multipart,
 
        /* we *must not* be in multipart state, otherwise the mime parser will
         * parse the headers which is a no no @#$ # stupid multipart/signed spec */
-       g_assert (camel_mime_parser_state (mp) == CAMEL_MIME_PARSER_STATE_HEADER);
+       g_return_val_if_fail (camel_mime_parser_state (mp) == CAMEL_MIME_PARSER_STATE_HEADER, -1);
 
        /* All we do is copy it to a memstream */
        content_type = camel_mime_parser_content_type (mp);
diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c
index db632ae..896e539 100644
--- a/camel/camel-multipart.c
+++ b/camel/camel-multipart.c
@@ -352,7 +352,7 @@ multipart_construct_from_parser (CamelMultipart *multipart,
        gchar *buf;
        gsize len;
 
-       g_assert (camel_mime_parser_state (mp) == CAMEL_MIME_PARSER_STATE_MULTIPART);
+       g_return_val_if_fail (camel_mime_parser_state (mp) == CAMEL_MIME_PARSER_STATE_MULTIPART, -1);
 
        content_type = camel_mime_parser_content_type (mp);
        camel_multipart_set_boundary (
diff --git a/camel/camel-nntp-address.c b/camel/camel-nntp-address.c
index c32424e..43ebe56 100644
--- a/camel/camel-nntp-address.c
+++ b/camel/camel-nntp-address.c
@@ -82,7 +82,7 @@ nntp_address_cat (CamelAddress *dest,
 {
        gint ii;
 
-       g_assert (CAMEL_IS_NNTP_ADDRESS (source));
+       g_return_val_if_fail (CAMEL_IS_NNTP_ADDRESS (source), -1);
 
        for (ii = 0; ii < source->addresses->len; ii++)
                camel_nntp_address_add (
@@ -150,7 +150,7 @@ camel_nntp_address_add (CamelNNTPAddress *a,
 {
        gint index, i;
 
-       g_assert (CAMEL_IS_NNTP_ADDRESS (a));
+       g_return_val_if_fail (CAMEL_IS_NNTP_ADDRESS (a), -1);
 
        index = ((CamelAddress *) a)->addresses->len;
        for (i = 0; i < index; i++)
@@ -177,7 +177,7 @@ camel_nntp_address_get (CamelNNTPAddress *a,
                         gint index,
                         const gchar **namep)
 {
-       g_assert (CAMEL_IS_NNTP_ADDRESS (a));
+       g_return_val_if_fail (CAMEL_IS_NNTP_ADDRESS (a), FALSE);
 
        if (index < 0 || index >= ((CamelAddress *) a)->addresses->len)
                return FALSE;
diff --git a/camel/camel-partition-table.c b/camel/camel-partition-table.c
index 9af8b4c..2e2fce4 100644
--- a/camel/camel-partition-table.c
+++ b/camel/camel-partition-table.c
@@ -789,14 +789,10 @@ camel_key_table_add (CamelKeyTable *ki,
 
        kblast->used++;
 
-#if 0
-       g_assert (kblast->used < 127);
-#else
        if (kblast->used >=127) {
                g_warning ("Invalid value for used %d\n", kblast->used);
                return 0;
        }
-#endif
 
        camel_block_file_touch_block (ki->blocks, last);
        camel_block_file_unref_block (ki->blocks, last);
diff --git a/camel/camel-sexp.c b/camel/camel-sexp.c
index 13e0391..1150a2c 100644
--- a/camel/camel-sexp.c
+++ b/camel/camel-sexp.c
@@ -228,7 +228,7 @@ camel_sexp_result_free (CamelSExp *sexp,
        case CAMEL_SEXP_RES_UNDEFINED:
                break;
        default:
-               g_assert_not_reached ();
+               g_return_if_reached ();
        }
        camel_memchunk_free (sexp->result_chunks, term);
 }
@@ -1261,8 +1261,8 @@ parse_values (CamelSExp *sexp,
        terms = g_malloc (size * sizeof (*terms));
        l = list;
        for (i = size - 1; i >= 0; i--) {
-               g_assert (l);
-               g_assert (l->data);
+               g_return_val_if_fail (l, NULL);
+               g_return_val_if_fail (l->data, NULL);
                terms[i] = l->data;
                l = g_slist_next (l);
        }
@@ -1337,7 +1337,7 @@ parse_value (CamelSExp *sexp)
 
                str = g_scanner_cur_value (gs).v_identifier;
 
-               g_assert (str != NULL);
+               g_return_val_if_fail (str != NULL, NULL);
                if (!(strlen (str) == 1 && (str[0] == 't' || str[0] == 'f'))) {
                        camel_sexp_fatal_error (sexp, "Invalid format for a boolean value");
                        return NULL;
diff --git a/camel/camel-store.c b/camel/camel-store.c
index cd2ddb5..6b9f990 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -905,12 +905,12 @@ add_special_info (CamelStore *store,
                g_free (vinfo->full_name);
                g_free (vinfo->display_name);
        } else {
+               g_return_if_fail (parent != NULL);
+
                /* There wasn't a Trash/Junk folder so create a new
                 * folder entry. */
                vinfo = camel_folder_info_new ();
 
-               g_assert (parent != NULL);
-
                vinfo->flags |=
                        CAMEL_FOLDER_NOINFERIORS |
                        CAMEL_FOLDER_SUBSCRIBED;
diff --git a/camel/camel-text-index.c b/camel/camel-text-index.c
index 952fb02..a7db523 100644
--- a/camel/camel-text-index.c
+++ b/camel/camel-text-index.c
@@ -215,8 +215,8 @@ text_index_finalize (GObject *object)
 
        priv = CAMEL_TEXT_INDEX_GET_PRIVATE (object);
 
-       g_assert (g_queue_is_empty (&priv->word_cache));
-       g_assert (g_hash_table_size (priv->words) == 0);
+       g_warn_if_fail (g_queue_is_empty (&priv->word_cache));
+       g_warn_if_fail (g_hash_table_size (priv->words) == 0);
 
        g_hash_table_destroy (priv->words);
 
@@ -1963,7 +1963,7 @@ main (gint argc,
                data = camel_key_table_lookup (ki, keyid, &key, &flags);
                m (printf (" word = '%s' %d %04x\n", key, data, flags));
 
-               g_assert (data == index && strcmp (key, line) == 0);
+               g_return_val_if_fail (data == index && strcmp (key, line) == 0, -1);
 
                g_free (key);
 
@@ -1983,7 +1983,7 @@ main (gint argc,
                data = camel_key_table_lookup (ki, keyid, &key, &flags);
                m (printf (" word = '%s' %d\n", key, data));
 
-               g_assert (data == index && strcmp (key, line) == 0);
+               g_return_val_if_fail (data == index && strcmp (key, line) == 0, -1);
 
                g_free (key);
 
diff --git a/camel/camel-url-scanner.c b/camel/camel-url-scanner.c
index 5ee9ab3..f209a17 100644
--- a/camel/camel-url-scanner.c
+++ b/camel/camel-url-scanner.c
@@ -203,7 +203,7 @@ camel_url_addrspec_start (const gchar *in,
 {
        register const gchar *inptr = pos;
 
-       g_assert (*inptr == '@');
+       g_return_val_if_fail (*inptr == '@', FALSE);
 
        if (inptr > in)
                inptr--;
@@ -242,7 +242,7 @@ camel_url_addrspec_end (const gchar *in,
        gint parts = 0, digits;
        gboolean got_dot = FALSE;
 
-       g_assert (*inptr == '@');
+       g_return_val_if_fail (*inptr == '@', FALSE);
 
        inptr++;
 
diff --git a/camel/camel-vtrash-folder.c b/camel/camel-vtrash-folder.c
index a29c93f..d554a60 100644
--- a/camel/camel-vtrash-folder.c
+++ b/camel/camel-vtrash-folder.c
@@ -246,7 +246,7 @@ camel_vtrash_folder_new (CamelStore *parent_store,
 {
        CamelVTrashFolder *vtrash;
 
-       g_assert (type < CAMEL_VTRASH_FOLDER_LAST);
+       g_return_val_if_fail (type < CAMEL_VTRASH_FOLDER_LAST, NULL);
 
        vtrash = g_object_new (
                CAMEL_TYPE_VTRASH_FOLDER,
diff --git a/camel/providers/imapx/camel-imapx-command.c b/camel/providers/imapx/camel-imapx-command.c
index 09e88ec..83fc2d3 100644
--- a/camel/providers/imapx/camel-imapx-command.c
+++ b/camel/providers/imapx/camel-imapx-command.c
@@ -426,7 +426,7 @@ camel_imapx_command_addv (CamelIMAPXCommand *ic,
                case '\\':      /* only for \\ really, we dont support \n\r etc at all */
                        c = *p;
                        if (c) {
-                               g_assert (c == '\\');
+                               g_warn_if_fail (c == '\\');
                                g_string_append_len (buffer, ps, p - ps);
                                p++;
                                ps = p;
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index d1653ab..165a07f 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -3311,7 +3311,7 @@ noskip:
                if (cp->type & (CAMEL_IMAPX_COMMAND_CONTINUATION | CAMEL_IMAPX_COMMAND_LITERAL_PLUS)) {
                        newliteral = ic;
                } else {
-                       g_assert (g_list_next (link) == NULL);
+                       g_warn_if_fail (g_list_next (link) == NULL);
                }
        } else {
                c (is->tagprefix, "%p: queueing continuation\n", ic);
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index c002bcf..2ab32da 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -688,7 +688,7 @@ camel_local_folder_lock (CamelLocalFolder *lf,
 {
        if (lf->locked > 0) {
                /* lets be anal here - its important the code knows what its doing */
-               g_assert (lf->locktype == type || lf->locktype == CAMEL_LOCK_WRITE);
+               g_return_val_if_fail (lf->locktype == type || lf->locktype == CAMEL_LOCK_WRITE, -1);
        } else {
                if (CAMEL_LOCAL_FOLDER_GET_CLASS (lf)->lock (lf, type, error) == -1)
                        return -1;
@@ -704,7 +704,7 @@ camel_local_folder_lock (CamelLocalFolder *lf,
 gint
 camel_local_folder_unlock (CamelLocalFolder *lf)
 {
-       g_assert (lf->locked > 0);
+       g_return_val_if_fail (lf->locked > 0, -1);
        lf->locked--;
        if (lf->locked == 0)
                CAMEL_LOCAL_FOLDER_GET_CLASS (lf)->unlock (lf);
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index 16cb1dd..a64b032 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -439,7 +439,7 @@ mbox_folder_lock (CamelLocalFolder *lf,
        CamelMboxFolder *mf = (CamelMboxFolder *) lf;
 
        /* make sure we have matching unlocks for locks, camel-local-folder class should enforce this */
-       g_assert (mf->lockfd == -1);
+       g_return_val_if_fail (mf->lockfd == -1, -1);
 
        mf->lockfd = open (lf->folder_path, O_RDWR | O_LARGEFILE, 0);
        if (mf->lockfd == -1) {
@@ -466,7 +466,7 @@ mbox_folder_unlock (CamelLocalFolder *lf)
 #ifndef G_OS_WIN32
        CamelMboxFolder *mf = (CamelMboxFolder *) lf;
 
-       g_assert (mf->lockfd != -1);
+       g_return_if_fail (mf->lockfd != -1);
        if (mf->lockfd != -1) {
                camel_unlock_folder (lf->folder_path, mf->lockfd);
                close (mf->lockfd);
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index 50335ed..fc5f2fe 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -530,7 +530,7 @@ summary_update (CamelLocalSummary *cls,
                info = camel_folder_summary_info_new_from_parser (s, mp);
                camel_folder_summary_add (s, info);
 
-               g_assert (camel_mime_parser_step (mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM_END);
+               g_warn_if_fail (camel_mime_parser_step (mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM_END);
        }
 
        g_object_unref (mp);
diff --git a/camel/providers/local/camel-mh-summary.c b/camel/providers/local/camel-mh-summary.c
index 46310eb..e58fcdb 100644
--- a/camel/providers/local/camel-mh-summary.c
+++ b/camel/providers/local/camel-mh-summary.c
@@ -321,7 +321,7 @@ mh_summary_sync (CamelLocalSummary *cls,
        known_uids = camel_folder_summary_get_array ((CamelFolderSummary *) cls);
        for (i = (known_uids ? known_uids->len : 0) - 1; i >= 0; i--) {
                info = (CamelLocalMessageInfo *) camel_folder_summary_get ((CamelFolderSummary *) cls, 
g_ptr_array_index (known_uids, i));
-               g_assert (info);
+               g_return_val_if_fail (info, -1);
                if (expunge && (info->info.flags & CAMEL_MESSAGE_DELETED)) {
                        uid = camel_message_info_uid (info);
                        name = g_strdup_printf ("%s/%s", cls->folder_path, uid);
diff --git a/camel/providers/local/camel-spool-summary.c b/camel/providers/local/camel-spool-summary.c
index 8d637a3..1b6c835 100644
--- a/camel/providers/local/camel-spool-summary.c
+++ b/camel/providers/local/camel-spool-summary.c
@@ -335,7 +335,7 @@ spool_summary_check (CamelLocalSummary *cls,
        known_uids = camel_folder_summary_get_array (s);
        for (i = 0; !work && known_uids && i < known_uids->len; i++) {
                CamelMboxMessageInfo *info = (CamelMboxMessageInfo *) camel_folder_summary_get (s, 
g_ptr_array_index (known_uids, i));
-               g_assert (info);
+               g_return_val_if_fail (info, -1);
                work = (info->info.info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV)) != 0;
                camel_message_info_unref (info);
        }
diff --git a/camel/providers/nntp/camel-nntp-store-summary.c b/camel/providers/nntp/camel-nntp-store-summary.c
index f939b58..e3664a9 100644
--- a/camel/providers/nntp/camel-nntp-store-summary.c
+++ b/camel/providers/nntp/camel-nntp-store-summary.c
@@ -376,7 +376,7 @@ store_info_set_string (CamelStoreSummary *s,
 {
        CamelNNTPStoreInfo *nsi = (CamelNNTPStoreInfo *) mi;
 
-       g_assert (mi != NULL);
+       g_return_if_fail (mi != NULL);
 
        switch (type) {
        case CAMEL_NNTP_STORE_INFO_FULL_NAME:
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 9e1b465..4c785e7 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -465,7 +465,7 @@ pop3_folder_get_message_sync (CamelFolder *folder,
                        ;
 
                /* getting error code? */
-               /*g_assert (fi->cmd->state == CAMEL_POP3_COMMAND_DATA);*/
+               /*g_warn_if_fail (fi->cmd->state == CAMEL_POP3_COMMAND_DATA);*/
                camel_pop3_engine_command_free (pop3_engine, fi->cmd);
                fi->cmd = NULL;
 
@@ -545,7 +545,7 @@ pop3_folder_get_message_sync (CamelFolder *folder,
                        ;
 
                /* getting error code? */
-               /*g_assert (pcr->state == CAMEL_POP3_COMMAND_DATA);*/
+               /*g_warn_if_fail (pcr->state == CAMEL_POP3_COMMAND_DATA);*/
                camel_pop3_engine_command_free (pop3_engine, pcr);
                g_seekable_seek (
                        G_SEEKABLE (stream), 0, G_SEEK_SET, NULL, NULL);
diff --git a/camel/tests/lib/camel-test.c b/camel/tests/lib/camel-test.c
index e6dfec5..9fdc6e4 100644
--- a/camel/tests/lib/camel-test.c
+++ b/camel/tests/lib/camel-test.c
@@ -209,7 +209,7 @@ void camel_test_pull (void)
 
        s = current_state ();
 
-       g_assert (s->state);
+       g_return_if_fail (s->state);
 
        if (camel_test_verbose > 3)
                printf ("Finish step: %s\n", s->state->what);
diff --git a/camel/tests/mime-filter/test-charset.c b/camel/tests/mime-filter/test-charset.c
index 1844fd6..c490396 100644
--- a/camel/tests/mime-filter/test-charset.c
+++ b/camel/tests/mime-filter/test-charset.c
@@ -197,7 +197,6 @@ main (gint argc,
 
        if (local_error != NULL) {
                g_error ("%s", local_error->message);
-               g_assert_not_reached ();
        }
 
        while ((basename = g_dir_read_name (dir)) != NULL)
diff --git a/examples/cursor/cursor-data.c b/examples/cursor/cursor-data.c
index c7fd19b..57bc51c 100644
--- a/examples/cursor/cursor-data.c
+++ b/examples/cursor/cursor-data.c
@@ -204,7 +204,7 @@ cursor_load_data (const gchar *vcard_path,
                        ESource *source = e_source_registry_ref_source (registry, CURSOR_DATA_SOURCE_ID);
 
                        g_clear_error (&error);
-                       g_assert (E_IS_SOURCE (source));
+                       g_return_val_if_fail (E_IS_SOURCE (source), NULL);
 
                        /* Run the callback which creates the addressbook client connection */
                        cursor_data_source_added (registry, source, NULL);
@@ -224,7 +224,7 @@ cursor_load_data (const gchar *vcard_path,
                g_main_loop_run (loop);
 
                /* By now we aborted or we have an addressbook created */
-               g_assert (address_book != NULL);
+               g_return_val_if_fail (address_book != NULL, NULL);
        }
 
        /**********************************************************
diff --git a/libedataserver/e-debug-log.c b/libedataserver/e-debug-log.c
index 10a17d5..9180eed 100644
--- a/libedataserver/e-debug-log.c
+++ b/libedataserver/e-debug-log.c
@@ -102,26 +102,26 @@ add_to_ring (gchar *str)
 {
        ensure_ring ();
 
-       g_assert (str != NULL);
+       g_return_if_fail (str != NULL);
 
        if (ring_buffer_num_lines == ring_buffer_max_lines) {
                /* We have an overlap, and the ring_buffer_next_index pogints to
                 * the "first" item.  Free it to make room for the new item.
                 */
 
-               g_assert (ring_buffer[ring_buffer_next_index] != NULL);
+               g_return_if_fail (ring_buffer[ring_buffer_next_index] != NULL);
                g_free (ring_buffer[ring_buffer_next_index]);
        } else
                ring_buffer_num_lines++;
 
-       g_assert (ring_buffer_num_lines <= ring_buffer_max_lines);
+       g_return_if_fail (ring_buffer_num_lines <= ring_buffer_max_lines);
 
        ring_buffer[ring_buffer_next_index] = str;
 
        ring_buffer_next_index++;
        if (ring_buffer_next_index == ring_buffer_max_lines) {
                ring_buffer_next_index = 0;
-               g_assert (ring_buffer_num_lines == ring_buffer_max_lines);
+               g_return_if_fail (ring_buffer_num_lines == ring_buffer_max_lines);
        }
 }
 
@@ -139,7 +139,7 @@ add_to_milestones (const gchar *str)
                milestones_head = milestones_tail = g_slist_append (NULL, str_copy);
        }
 
-       g_assert (milestones_head != NULL && milestones_tail != NULL);
+       g_return_if_fail (milestones_head != NULL && milestones_tail != NULL);
 }
 
 /**
@@ -204,8 +204,8 @@ e_debug_log_load_configuration (const gchar *filename,
        gint num;
        GError *my_error;
 
-       g_assert (filename != NULL);
-       g_assert (error == NULL || *error == NULL);
+       g_return_val_if_fail (filename != NULL, FALSE);
+       g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
        key_file = g_key_file_new ();
 
@@ -260,8 +260,8 @@ e_debug_log_enable_domains (const gchar **domains,
 {
        gint i;
 
-       g_assert (domains != NULL);
-       g_assert (n_domains >= 0);
+       g_return_if_fail (domains != NULL);
+       g_return_if_fail (n_domains >= 0);
 
        lock ();
 
@@ -269,7 +269,7 @@ e_debug_log_enable_domains (const gchar **domains,
                domains_hash = g_hash_table_new (g_str_hash, g_str_equal);
 
        for (i = 0; i < n_domains; i++) {
-               g_assert (domains[i] != NULL);
+               g_return_if_fail (domains[i] != NULL);
 
                if (strcmp (domains[i], E_DEBUG_LOG_DOMAIN_USER) == 0)
                        continue; /* user actions are always enabled */
@@ -296,8 +296,8 @@ e_debug_log_disable_domains (const gchar **domains,
 {
        gint i;
 
-       g_assert (domains != NULL);
-       g_assert (n_domains >= 0);
+       g_return_if_fail (domains != NULL);
+       g_return_if_fail (n_domains >= 0);
 
        lock ();
 
@@ -305,7 +305,7 @@ e_debug_log_disable_domains (const gchar **domains,
                for (i = 0; i < n_domains; i++) {
                        gchar *domain;
 
-                       g_assert (domains[i] != NULL);
+                       g_return_if_fail (domains[i] != NULL);
 
                        if (strcmp (domains[i], E_DEBUG_LOG_DOMAIN_USER) == 0)
                                continue; /* user actions are always enabled */
@@ -331,7 +331,7 @@ e_debug_log_is_domain_enabled (const gchar *domain)
 {
        gboolean retval;
 
-       g_assert (domain != NULL);
+       g_return_val_if_fail (domain != NULL, FALSE);
 
        lock ();
        retval = is_domain_enabled (domain);
@@ -381,7 +381,7 @@ make_key_file_from_configuration (void)
                                domains_hash,
                                domains_foreach_dump_cb,
                                &closure);
-                       g_assert (num_domains == closure.num_domains);
+                       g_return_val_if_fail (num_domains == closure.num_domains, NULL);
 
                        g_key_file_set_string_list (
                                key_file,
@@ -531,7 +531,7 @@ e_debug_log_dump (const gchar *filename,
        FILE *file;
        gboolean success;
 
-       g_assert (error == NULL || *error == NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
        lock ();
 
@@ -598,7 +598,7 @@ e_debug_log_dump_to_dated_file (GError **error)
        gchar *filename;
        gboolean retval;
 
-       g_assert (error == NULL || *error == NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
        t = time (NULL);
        tm = *localtime (&t);
@@ -632,7 +632,7 @@ e_debug_log_set_max_lines (gint num_lines)
        gchar **new_buffer;
        gint lines_to_copy;
 
-       g_assert (num_lines > 0);
+       g_return_if_fail (num_lines > 0);
 
        lock ();
 
@@ -655,7 +655,7 @@ e_debug_log_set_max_lines (gint num_lines)
                else
                        start_index = ring_buffer_num_lines - lines_to_copy;
 
-               g_assert (start_index >= 0 && start_index < ring_buffer_max_lines);
+               g_return_if_fail (start_index >= 0 && start_index < ring_buffer_max_lines);
 
                for (i = 0; i < lines_to_copy; i++) {
                        gint idx;
diff --git a/libedataserver/e-gdbus-templates.c b/libedataserver/e-gdbus-templates.c
index 208d607..530bc7f 100644
--- a/libedataserver/e-gdbus-templates.c
+++ b/libedataserver/e-gdbus-templates.c
@@ -86,7 +86,7 @@ e_gdbus_signal_emission_hook_boolean (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 1);
+       g_return_val_if_fail (n_param_values - 1 == 1, FALSE);
        param_values++;
        item = g_variant_new_boolean (g_value_get_boolean (param_values));
        g_variant_builder_add_value (builder, item);
@@ -123,7 +123,7 @@ e_gdbus_signal_emission_hook_string (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 1);
+       g_return_val_if_fail (n_param_values - 1 == 1, FALSE);
        param_values++;
        item = g_variant_new_string (g_value_get_string (param_values));
        g_variant_builder_add_value (builder, item);
@@ -161,7 +161,7 @@ e_gdbus_signal_emission_hook_strv (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 1);
+       g_return_val_if_fail (n_param_values - 1 == 1, FALSE);
        param_values++;
        arg_strv = g_value_get_boxed (param_values);
        item = g_variant_new_strv (arg_strv, -1);
@@ -199,7 +199,7 @@ e_gdbus_signal_emission_hook_uint (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 1);
+       g_return_val_if_fail (n_param_values - 1 == 1, FALSE);
        param_values++;
        item = g_variant_new_uint32 (g_value_get_uint (param_values));
        g_variant_builder_add_value (builder, item);
@@ -236,7 +236,7 @@ e_gdbus_signal_emission_hook_uint_string (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 2);
+       g_return_val_if_fail (n_param_values - 1 == 2, FALSE);
        param_values++;
        item = g_variant_new_uint32 (g_value_get_uint (param_values));
        g_variant_builder_add_value (builder, item);
@@ -277,7 +277,7 @@ e_gdbus_signal_emission_hook_async_void (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 2);
+       g_return_val_if_fail (n_param_values - 1 == 2, FALSE);
        param_values++;
        item = g_variant_new_uint32 (g_value_get_uint (param_values));
        g_variant_builder_add_value (builder, item);
@@ -331,7 +331,7 @@ e_gdbus_signal_emission_hook_async_boolean (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 3);
+       g_return_val_if_fail (n_param_values - 1 == 3, FALSE);
        param_values++;
        item = g_variant_new_uint32 (g_value_get_uint (param_values));
        g_variant_builder_add_value (builder, item);
@@ -392,7 +392,7 @@ e_gdbus_signal_emission_hook_async_string (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 3);
+       g_return_val_if_fail (n_param_values - 1 == 3, FALSE);
        param_values++;
        item = g_variant_new_uint32 (g_value_get_uint (param_values));
        g_variant_builder_add_value (builder, item);
@@ -454,7 +454,7 @@ e_gdbus_signal_emission_hook_async_strv (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 3);
+       g_return_val_if_fail (n_param_values - 1 == 3, FALSE);
        param_values++;
        item = g_variant_new_uint32 (g_value_get_uint (param_values));
        g_variant_builder_add_value (builder, item);
@@ -518,7 +518,7 @@ e_gdbus_signal_emission_hook_async_uint (GSignalInvocationHint *ihint,
                return FALSE;
 
        builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
-       g_assert_cmpint (n_param_values - 1, ==, 3);
+       g_return_val_if_fail (n_param_values - 1 == 3, FALSE);
        param_values++;
        item = g_variant_new_uint32 (g_value_get_uint (param_values));
        g_variant_builder_add_value (builder, item);
diff --git a/libedataserver/e-sexp.c b/libedataserver/e-sexp.c
index 32d1b35..0f9764c 100644
--- a/libedataserver/e-sexp.c
+++ b/libedataserver/e-sexp.c
@@ -214,7 +214,7 @@ e_sexp_result_free (struct _ESExp *f,
        case ESEXP_RES_UNDEFINED:
                break;
        default:
-               g_assert_not_reached ();
+               g_return_if_reached ();
        }
        e_memchunk_free (f->result_chunks, t);
 }
@@ -1233,8 +1233,8 @@ parse_values (ESExp *f,
        terms = g_malloc (size * sizeof (*terms));
        l = list;
        for (i = size - 1; i >= 0; i--) {
-               g_assert (l);
-               g_assert (l->data);
+               g_return_val_if_fail (l, NULL);
+               g_return_val_if_fail (l->data, NULL);
                terms[i] = l->data;
                l = g_slist_next (l);
        }
@@ -1313,7 +1313,7 @@ parse_value (ESExp *f)
 
                str = g_scanner_cur_value (gs).v_identifier;
 
-               g_assert (str != NULL);
+               g_return_val_if_fail (str != NULL, NULL);
                if (!(strlen (str) == 1 && (str[0] == 't' || str[0] == 'f'))) {
                        e_sexp_fatal_error (
                                f, "Invalid format for a boolean value");
diff --git a/services/evolution-source-registry/evolution-source-registry-migrate-sources.c 
b/services/evolution-source-registry/evolution-source-registry-migrate-sources.c
index c14bb90..4c4cf0c 100644
--- a/services/evolution-source-registry/evolution-source-registry-migrate-sources.c
+++ b/services/evolution-source-registry/evolution-source-registry-migrate-sources.c
@@ -389,7 +389,10 @@ migrate_parse_commit_changes (ParseType parse_type,
                        goto exit;
        }
 
-       g_assert (mangled_uri != NULL);
+       if (!mangled_uri) {
+               g_warn_if_reached ();
+               goto exit;
+       }
 
        old_directory = g_build_filename (
                cache_dir, component, mangled_uri, NULL);
diff --git a/tests/book-migration/setup-migration-test.c b/tests/book-migration/setup-migration-test.c
index f3e8b8a..9021f5d 100644
--- a/tests/book-migration/setup-migration-test.c
+++ b/tests/book-migration/setup-migration-test.c
@@ -197,7 +197,7 @@ create_book (const gchar *book_id)
                g_main_loop_run (data.loop);
 
                /* By now we aborted or we have an addressbook created */
-               g_assert (data.book != NULL);
+               g_warn_if_fail (data.book != NULL);
        }
 
        g_main_loop_unref (data.loop);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]