From: Milan Crha Date: Tue, 14 Feb 2012 09:32:05 +0000 (+0100) Subject: Fix issues found by Coverity Scan X-Git-Tag: upstream/3.7.4~1171 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9ad01ba73afb402f194c2f66a90432e47003091;p=platform%2Fupstream%2Fevolution-data-server.git Fix issues found by Coverity Scan --- diff --git a/addressbook/backends/ldap/e-book-backend-ldap.c b/addressbook/backends/ldap/e-book-backend-ldap.c index 470f6ae..58f5a45 100644 --- a/addressbook/backends/ldap/e-book-backend-ldap.c +++ b/addressbook/backends/ldap/e-book-backend-ldap.c @@ -4365,7 +4365,7 @@ e_book_backend_ldap_build_query (EBookBackendLDAP *bl, } else { if (bl->priv->ldap_search_filter && *bl->priv->ldap_search_filter - && g_ascii_strncasecmp(bl->priv->ldap_search_filter,"(objectClass=*)",sizeof(bl->priv->ldap_search_filter))) { + && g_ascii_strcasecmp (bl->priv->ldap_search_filter, "(objectClass=*)") != 0) { strings = g_new0 (gchar *, 5); strings[0] = g_strdup ("(&"); strings[1] = g_strdup_printf ("%s", bl->priv->ldap_search_filter); @@ -4646,9 +4646,12 @@ poll_ldap (EBookBackendLDAP *bl) if (rc != 0) {/* rc == 0 means timeout exceeded */ if (rc == -1) { EDataBookView *book_view = find_book_view (bl); - g_warning ("ldap_result returned -1, restarting ops"); + g_warning ("%s: ldap_result returned -1, restarting ops", G_STRFUNC); - e_book_backend_ldap_reconnect (bl, book_view, LDAP_SERVER_DOWN); + if (!e_book_backend_ldap_reconnect (bl, book_view, LDAP_SERVER_DOWN)) { + g_warning ("%s: Failed to reconnect to LDAP server", G_STRFUNC); + return FALSE; + } #if 0 if (bl->priv->connected) restart_ops (bl); @@ -4852,9 +4855,9 @@ e_book_backend_ldap_search (EBookBackendLDAP *bl, g_static_rec_mutex_unlock (&eds_ldap_handler_lock); - view_limit = -1; - if (view_limit == -1 || view_limit > bl->priv->ldap_limit) - view_limit = bl->priv->ldap_limit; + view_limit = bl->priv->ldap_limit; + /* if (view_limit == -1 || view_limit > bl->priv->ldap_limit) + view_limit = bl->priv->ldap_limit; */ if (enable_debug) printf ("searching server using filter: %s (expecting max %d results)\n", ldap_query, view_limit); diff --git a/addressbook/libebook/e-book-query.c b/addressbook/libebook/e-book-query.c index a839b87..fd5421f 100644 --- a/addressbook/libebook/e-book-query.c +++ b/addressbook/libebook/e-book-query.c @@ -118,7 +118,6 @@ conjoinv (EBookQueryType type, g_ptr_array_add (qs, q); q = va_arg (ap, EBookQuery *); } - va_end (ap); ret->type = type; ret->query.andor.nqs = qs->len; @@ -140,10 +139,14 @@ conjoinv (EBookQueryType type, EBookQuery * e_book_query_andv (EBookQuery *q, ...) { + EBookQuery *res; va_list ap; va_start (ap, q); - return conjoinv (E_BOOK_QUERY_TYPE_AND, q, ap); + res = conjoinv (E_BOOK_QUERY_TYPE_AND, q, ap); + va_end (ap); + + return res; } /** @@ -158,10 +161,14 @@ e_book_query_andv (EBookQuery *q, ...) EBookQuery * e_book_query_orv (EBookQuery *q, ...) { + EBookQuery *res; va_list ap; va_start (ap, q); - return conjoinv (E_BOOK_QUERY_TYPE_OR, q, ap); + res = conjoinv (E_BOOK_QUERY_TYPE_OR, q, ap); + va_end (ap); + + return res; } /** diff --git a/addressbook/libebook/e-contact.c b/addressbook/libebook/e-contact.c index 22ac944..f7acc55 100644 --- a/addressbook/libebook/e-contact.c +++ b/addressbook/libebook/e-contact.c @@ -1380,7 +1380,7 @@ e_contact_duplicate (EContact *contact) const gchar * e_contact_field_name (EContactField field_id) { - g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, ""); + g_return_val_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST, ""); return field_info[field_id].field_name; } @@ -1397,7 +1397,7 @@ e_contact_field_name (EContactField field_id) const gchar * e_contact_pretty_name (EContactField field_id) { - g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, ""); + g_return_val_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST, ""); #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); @@ -1418,7 +1418,7 @@ e_contact_pretty_name (EContactField field_id) const gchar * e_contact_vcard_attribute (EContactField field_id) { - g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, ""); + g_return_val_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST, ""); return field_info[field_id].vcard_field_name; } @@ -1487,7 +1487,7 @@ e_contact_get (EContact *contact, const EContactFieldInfo *info = NULL; g_return_val_if_fail (contact && E_IS_CONTACT (contact), NULL); - g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, NULL); + g_return_val_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST, NULL); info = &field_info[field_id]; @@ -1689,6 +1689,7 @@ e_contact_get_const (EContact *contact, gpointer value = NULL; g_return_val_if_fail (E_IS_CONTACT (contact), NULL); + g_return_val_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST, NULL); g_return_val_if_fail (field_info[field_id].t & E_CONTACT_FIELD_TYPE_STRING, NULL); value = contact->priv->cached_strings[field_id]; @@ -1718,7 +1719,7 @@ e_contact_set (EContact *contact, d(printf ("e_contact_set (%p, %d, %p)\n", contact, field_id, value)); g_return_if_fail (contact && E_IS_CONTACT (contact)); - g_return_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST); + g_return_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST); /* set the cached slot to NULL so we'll re-get the new string * if e_contact_get_const is called again */ @@ -1748,7 +1749,7 @@ e_contact_get_attributes (EContact *contact, const EContactFieldInfo *info = NULL; g_return_val_if_fail (contact && E_IS_CONTACT (contact), NULL); - g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, NULL); + g_return_val_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST, NULL); info = &field_info[field_id]; @@ -1786,7 +1787,7 @@ e_contact_set_attributes (EContact *contact, GList *l; g_return_if_fail (contact && E_IS_CONTACT (contact)); - g_return_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST); + g_return_if_fail (field_id >= 1 && field_id < E_CONTACT_FIELD_LAST); info = &field_info[field_id]; @@ -1856,7 +1857,7 @@ e_contact_name_from_string (const gchar *name_str) g_return_val_if_fail (name_str != NULL, NULL); name = e_contact_name_new (); - western = e_name_western_parse (name_str ? name_str : ""); + western = e_name_western_parse (name_str); name->prefixes = g_strdup (western->prefix); name->given = g_strdup (western->first ); diff --git a/addressbook/libebook/e-vcard.c b/addressbook/libebook/e-vcard.c index aa915a6..0d1aade 100644 --- a/addressbook/libebook/e-vcard.c +++ b/addressbook/libebook/e-vcard.c @@ -1406,7 +1406,7 @@ e_vcard_attribute_get_type (void) * e_vcard_remove_attributes: * @evc: vcard object * @attr_group: (allow-none): group name of attributes to be removed - * @attr_name: (allow-none): name of the arributes to be removed + * @attr_name: name of the arributes to be removed * * Removes all the attributes with group name and attribute name equal to * passed in values. If @attr_group is %NULL or an empty string, @@ -1432,7 +1432,7 @@ e_vcard_remove_attributes (EVCard *evc, if (((!attr_group || *attr_group == '\0') || (attr_group && !g_ascii_strcasecmp (attr_group, a->group))) && - ((!attr_name && !a->name) || !g_ascii_strcasecmp (attr_name, a->name))) { + ((!a->name) || !g_ascii_strcasecmp (attr_name, a->name))) { /* matches, remove/delete the attribute */ evc->priv->attributes = g_list_delete_link (evc->priv->attributes, attr); diff --git a/addressbook/libedata-book/e-book-backend-db-cache.c b/addressbook/libedata-book/e-book-backend-db-cache.c index 2a6daf0..7c52cc4 100644 --- a/addressbook/libedata-book/e-book-backend-db-cache.c +++ b/addressbook/libedata-book/e-book-backend-db-cache.c @@ -32,7 +32,7 @@ void string_to_dbt (const gchar *str, DBT *dbt) { - memset (dbt, 0, sizeof (dbt)); + memset (dbt, 0, sizeof (DBT)); dbt->data = (gpointer) str; dbt->size = strlen (str) + 1; dbt->flags = DB_DBT_USERMEM; @@ -299,7 +299,7 @@ e_book_backend_db_cache_get_contacts (DB *db, if (vcard_dbt.data && !strncmp (vcard_dbt.data, "BEGIN:VCARD", 11)) { contact = e_contact_new_from_vcard (vcard_dbt.data); - if (e_book_backend_sexp_match_contact (sexp, contact)) + if (!sexp || e_book_backend_sexp_match_contact (sexp, contact)) list = g_list_prepend (list, contact); else g_object_unref (contact); diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb-test.c b/addressbook/libedata-book/e-book-backend-sqlitedb-test.c index 2525268..7e703bb 100644 --- a/addressbook/libedata-book/e-book-backend-sqlitedb-test.c +++ b/addressbook/libedata-book/e-book-backend-sqlitedb-test.c @@ -115,13 +115,12 @@ start_tests (gpointer data) gchar *vcard_str = NULL, *sexp; EBookQuery *q; GSList *uids = NULL; - gboolean store_vcard = FALSE; g_print ("Creating the sqlitedb \n"); op = "create sqlitedb"; ebsdb = e_book_backend_sqlitedb_new (cache_path, email, folderid, folder_name, - store_vcard, &error); + FALSE, &error); if (error) goto exit; @@ -164,7 +163,7 @@ start_tests (gpointer data) if (error) goto exit; - if (store_vcard) { + /* if (store_vcard) { q = e_book_query_any_field_contains ("word"); sexp = e_book_query_to_string (q); search_db (ebsdb, "full_search query", sexp); @@ -172,7 +171,7 @@ start_tests (gpointer data) g_free (sexp); if (error) goto exit; - } + } */ g_print ("Delete contact \n"); op = "delete contact"; diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb.c b/addressbook/libedata-book/e-book-backend-sqlitedb.c index bc49ddf..7e6e82a 100644 --- a/addressbook/libedata-book/e-book-backend-sqlitedb.c +++ b/addressbook/libedata-book/e-book-backend-sqlitedb.c @@ -1421,8 +1421,10 @@ sexp_to_sql_query (const gchar *query) res = g_strdup (r->value.string); else res = NULL; - } else + } else { g_warn_if_reached (); + res = NULL; + } e_sexp_result_free (sexp, r); e_sexp_unref (sexp); diff --git a/addressbook/libedata-book/e-book-backend-summary.c b/addressbook/libedata-book/e-book-backend-summary.c index bf49ace..637286a 100644 --- a/addressbook/libedata-book/e-book-backend-summary.c +++ b/addressbook/libedata-book/e-book-backend-summary.c @@ -727,8 +727,7 @@ e_book_backend_summary_save (EBookBackendSummary *summary) lose: if (fp) fclose (fp); - if (new_filename) - g_unlink (new_filename); + g_unlink (new_filename); g_free (new_filename); return FALSE; } diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c index b4ba3c9..32e2d19 100644 --- a/calendar/backends/caldav/e-cal-backend-caldav.c +++ b/calendar/backends/caldav/e-cal-backend-caldav.c @@ -1718,7 +1718,7 @@ caldav_receive_schedule_outbox_url (ECalBackendCalDAV *cbdav) nsdav = xmlNewNs (root, (xmlChar *) "DAV:", NULL); node = xmlNewTextChild (root, nsdav, (xmlChar *) "prop", NULL); - node = xmlNewTextChild (node, nsdav, (xmlChar *) "owner", NULL); + xmlNewTextChild (node, nsdav, (xmlChar *) "owner", NULL); buf = xmlAllocOutputBuffer (NULL); xmlNodeDumpOutput (buf, doc, root, 0, 1, NULL); @@ -1768,7 +1768,7 @@ caldav_receive_schedule_outbox_url (ECalBackendCalDAV *cbdav) nscd = xmlNewNs (root, (xmlChar *) "urn:ietf:params:xml:ns:caldav", (xmlChar *) "C"); node = xmlNewTextChild (root, nsdav, (xmlChar *) "prop", NULL); - node = xmlNewTextChild (node, nscd, (xmlChar *) "schedule-outbox-URL", NULL); + xmlNewTextChild (node, nscd, (xmlChar *) "schedule-outbox-URL", NULL); buf = xmlAllocOutputBuffer (NULL); xmlNodeDumpOutput (buf, doc, root, 0, 1, NULL); @@ -2501,6 +2501,8 @@ initialize_backend (ECalBackendCalDAV *cbdav, soup_uri_free (suri); } + g_return_val_if_fail (priv->uri != NULL, FALSE); + /* remove trailing slashes... */ len = strlen (priv->uri); while (len--) { @@ -4452,8 +4454,6 @@ caldav_get_object_list (ECalBackendSync *backend, prunning_by_time = e_cal_backend_sexp_evaluate_occur_times (sexp, &occur_start, &occur_end); - bkend = E_CAL_BACKEND (backend); - list = prunning_by_time ? e_cal_backend_store_get_components_occuring_in_range (priv->store, occur_start, occur_end) : e_cal_backend_store_get_components (priv->store); diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c b/calendar/backends/contacts/e-cal-backend-contacts.c index 7093067..10e0c22 100644 --- a/calendar/backends/contacts/e-cal-backend-contacts.c +++ b/calendar/backends/contacts/e-cal-backend-contacts.c @@ -1320,6 +1320,9 @@ init_sources_cb (ECalBackendContacts *cbc) priv = cbc->priv; + if (!priv->addressbook_sources) + return NULL; + /* Create address books for existing sources */ for (i = e_source_list_peek_groups (priv->addressbook_sources); i; i = i->next) { ESourceGroup *source_group = E_SOURCE_GROUP (i->data); @@ -1508,7 +1511,8 @@ e_cal_backend_contacts_finalize (GObject *object) priv->update_alarms_id = 0; } - g_object_unref (priv->addressbook_sources); + if (priv->addressbook_sources) + g_object_unref (priv->addressbook_sources); g_hash_table_destroy (priv->addressbooks); g_hash_table_destroy (priv->credentials); g_hash_table_destroy (priv->tracked_contacts); @@ -1537,7 +1541,8 @@ e_cal_backend_contacts_init (ECalBackendContacts *cbc) priv = g_new0 (ECalBackendContactsPrivate, 1); - e_book_client_get_sources (&priv->addressbook_sources, NULL); + if (!e_book_client_get_sources (&priv->addressbook_sources, NULL)) + priv->addressbook_sources = NULL; priv->addressbooks = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) book_record_free); diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c index cc2a908..349f0fb 100644 --- a/calendar/backends/file/e-cal-backend-file.c +++ b/calendar/backends/file/e-cal-backend-file.c @@ -157,6 +157,7 @@ save_file_when_idle (gpointer user_data) GError *e = NULL; GFile *file, *backup_file; GFileOutputStream *stream; + gboolean succeeded; gchar *tmp, *backup_uristr; gchar *buf; ECalBackendFile *cbfile = user_data; @@ -208,20 +209,20 @@ save_file_when_idle (gpointer user_data) } buf = icalcomponent_as_ical_string_r (priv->icalcomp); - g_output_stream_write_all (G_OUTPUT_STREAM (stream), buf, strlen (buf) * sizeof (gchar), NULL, NULL, &e); + succeeded = g_output_stream_write_all (G_OUTPUT_STREAM (stream), buf, strlen (buf) * sizeof (gchar), NULL, NULL, &e); g_free (buf); - if (e) { + if (!succeeded || e) { g_object_unref (stream); g_object_unref (file); g_object_unref (backup_file); goto error; } - g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, &e); + succeeded = g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, &e); g_object_unref (stream); - if (e) { + if (!succeeded || e) { g_object_unref (file); g_object_unref (backup_file); goto error; @@ -2900,8 +2901,8 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, break; case CALOBJ_MOD_ONLY_THIS: case CALOBJ_MOD_THIS : - obj_data = remove_instance (cbfile, obj_data, uid, recur_id, mod, - old_component, new_component, error); + remove_instance (cbfile, obj_data, uid, recur_id, mod, + old_component, new_component, error); break; case CALOBJ_MOD_THISANDPRIOR : case CALOBJ_MOD_THISANDFUTURE : @@ -3824,10 +3825,9 @@ main (gint argc, } cbfile = g_object_new (E_TYPE_CAL_BACKEND_FILE, NULL); - open_cal (cbfile, calendar_fname, NULL); - if (cbfile == NULL) - { - g_message (G_STRLOC " Could not open calendar %s", calendar_fname); + open_cal (cbfile, calendar_fname, &error); + if (error != NULL) { + g_message (G_STRLOC " Could not open calendar %s: %s", calendar_fname, error->message); exit (-1); } diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c index c378f45..c81a4ed 100644 --- a/calendar/backends/http/e-cal-backend-http.c +++ b/calendar/backends/http/e-cal-backend-http.c @@ -1181,8 +1181,6 @@ create_user_free_busy (ECalBackendHttp *cbhttp, if (!obj_sexp) return vfb; - if (!obj_sexp) - return vfb; slist = e_cal_backend_store_get_components (store); diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c index d47754f..ab6b0f3 100644 --- a/calendar/backends/weather/e-cal-backend-weather.c +++ b/calendar/backends/weather/e-cal-backend-weather.c @@ -639,10 +639,9 @@ e_cal_backend_weather_get_object_list (ECalBackendSync *backend, } *objects = NULL; - components = e_cal_backend_store_get_components (priv->store); prunning_by_time = e_cal_backend_sexp_evaluate_occur_times (sexp, - &occur_start, - &occur_end); + &occur_start, + &occur_end); components = prunning_by_time ? e_cal_backend_store_get_components_occuring_in_range (priv->store, occur_start, occur_end) diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c index 383d0c3..151ab9d 100644 --- a/calendar/libecal/e-cal-client.c +++ b/calendar/libecal/e-cal-client.c @@ -1593,7 +1593,7 @@ get_objects_sync (ECalClient *client, try_again: if (!e_cal_client_get_objects_for_uid_sync (client, uid, &objects, NULL, &error)) { - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_BUSY) && tries >= 10) { + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_BUSY) && tries <= 10) { tries++; g_usleep (500); g_clear_error (&error); diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c index bef8cab..26b5066 100644 --- a/calendar/libecal/e-cal.c +++ b/calendar/libecal/e-cal.c @@ -3063,6 +3063,8 @@ process_detached_instances (GList *instances, ECalComponentRange recur_id, instance_recur_id; processed = FALSE; + recur_id.type = E_CAL_COMPONENT_RANGE_SINGLE; + instance_recur_id.type = E_CAL_COMPONENT_RANGE_SINGLE; cid = dl->data; e_cal_component_get_uid (cid->comp, &uid); @@ -4377,7 +4379,7 @@ e_cal_get_timezone (ECal *ecal, g_hash_table_insert (priv->timezones, (gpointer) icaltimezone_get_tzid (*zone), *zone); UNLOCK_CACHE (); - E_CALENDAR_CHECK_STATUS (status, error); + return TRUE; } /** diff --git a/calendar/libedata-cal/e-cal-backend-sexp.c b/calendar/libedata-cal/e-cal-backend-sexp.c index 121ad1e..cc0b8d6 100644 --- a/calendar/libedata-cal/e-cal-backend-sexp.c +++ b/calendar/libedata-cal/e-cal-backend-sexp.c @@ -558,7 +558,6 @@ func_due_in_time_range (ESExp *esexp, if (dt.value != NULL) { zone = resolve_tzid (dt.tzid, ctx); - result = e_sexp_result_new (esexp, ESEXP_RES_INT); if (zone) due_t = icaltime_as_timet_with_zone (*dt.value,zone); else diff --git a/camel/camel-certdb.c b/camel/camel-certdb.c index 4e1c6a4..68bac3f 100644 --- a/camel/camel-certdb.c +++ b/camel/camel-certdb.c @@ -248,6 +248,10 @@ camel_certdb_load (CamelCertDB *certdb) return -1; class = CAMEL_CERTDB_GET_CLASS (certdb); + if (!class->header_load || !class->cert_load) { + fclose (in); + in = NULL; + } g_return_val_if_fail (class->header_load != NULL, -1); g_return_val_if_fail (class->cert_load != NULL, -1); @@ -348,6 +352,10 @@ camel_certdb_save (CamelCertDB *certdb) } class = CAMEL_CERTDB_GET_CLASS (certdb); + if (!class->header_save || !class->cert_save) { + fclose (out); + out = NULL; + } g_return_val_if_fail (class->header_save != NULL, -1); g_return_val_if_fail (class->cert_save != NULL, -1); diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c index 78fa167..b74f277 100644 --- a/camel/camel-filter-driver.c +++ b/camel/camel-filter-driver.c @@ -428,6 +428,7 @@ report_status (CamelFilterDriver *driver, if (driver->priv->statusfunc) { va_start (ap, desc); str = g_strdup_vprintf (desc, ap); + va_end (ap); driver->priv->statusfunc (driver, status, pc, str, driver->priv->statusdata); g_free (str); } @@ -1184,6 +1185,7 @@ camel_filter_driver_log (CamelFilterDriver *driver, va_start (ap, desc); str = g_strdup_vprintf (desc, ap); + va_end (ap); } switch (status) { @@ -1355,7 +1357,8 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, goto fail; } /* to get the filesize */ - fstat (fd, &st); + if (fstat (fd, &st) != 0) + st.st_size = 0; mp = camel_mime_parser_new (); camel_mime_parser_scan_from (mp, TRUE); diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index 1641b68..42e7fcf 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -2467,15 +2467,17 @@ save_to_db_cb (gpointer key, } } + g_return_if_fail (mir != NULL); + if (!args->migration) { if (camel_db_write_message_info_record (cdb, full_name, mir, error) != 0) { - camel_db_camel_mir_free (mir); - return; + camel_db_camel_mir_free (mir); + return; } } else { if (camel_db_write_fresh_message_info_record (cdb, CAMEL_DB_IN_MEMORY_TABLE, mir, error) != 0) { - camel_db_camel_mir_free (mir); - return; + camel_db_camel_mir_free (mir); + return; } if (args->progress > CAMEL_DB_IN_MEMORY_TABLE_LIMIT) { @@ -2559,6 +2561,8 @@ camel_folder_summary_save_to_db (CamelFolderSummary *summary, CamelFIRecord *record; gint ret, count; + g_return_val_if_fail (summary != NULL, FALSE); + if (!(summary->flags & CAMEL_SUMMARY_DIRTY)) return TRUE; @@ -2698,11 +2702,7 @@ camel_folder_summary_header_load_from_db (CamelFolderSummary *summary, record = g_new0 (CamelFIRecord, 1); camel_db_read_folder_info_record (cdb, folder_name, record, error); - if (record) { - ret = CAMEL_FOLDER_SUMMARY_GET_CLASS (summary)->summary_header_from_db (summary, record); - } else { - ret = FALSE; - } + ret = CAMEL_FOLDER_SUMMARY_GET_CLASS (summary)->summary_header_from_db (summary, record); g_free (record->folder_name); g_free (record->bdata); diff --git a/camel/camel-folder.c b/camel/camel-folder.c index e14a6a1..e03f92b 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -1133,9 +1133,8 @@ fetch_messages_finish (CamelFolder *folder, async_context = g_simple_async_result_get_op_res_gpointer (simple); /* Assume success unless a GError is set. */ - g_simple_async_result_propagate_error (simple, error); - - return async_context->success; + return !g_simple_async_result_propagate_error (simple, error) + && async_context->success; } static void @@ -1345,9 +1344,8 @@ purge_message_cache_finish (CamelFolder *folder, async_context = g_simple_async_result_get_op_res_gpointer (simple); /* Assume success unless a GError is set. */ - g_simple_async_result_propagate_error (simple, error); - - return async_context->success; + return !g_simple_async_result_propagate_error (simple, error) + && async_context->success; } static void diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index 6ce5930..477d345 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -935,7 +935,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, i++; } - if (str && *str && i == 2) { + if (*str && i == 2) { struct { gint gpg_hash_algo; CamelCipherHash camel_hash_algo; diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index 2829bd9..7c08c82 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -206,8 +206,6 @@ camel_mime_message_build_preview (CamelMimePart *msg, /* We should fetch just 200 unquoted lines. */ while ((line = camel_stream_buffer_read_line ((CamelStreamBuffer *) bstream, NULL, NULL)) && str->len < 200) { gchar *tmp = line; - if (!line) - continue; if (*line == '>' || strstr(line, "wrote:")) { g_free (tmp); diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 55393e2..1d620df 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -3490,7 +3490,7 @@ camel_header_param_list_format_append (GString *out, if (!encoded) { gchar *ch; - for (ch = value; *ch; ch++) { + for (ch = value; ch && *ch; ch++) { if (camel_mime_is_tspecial (*ch) || camel_mime_is_lwsp (*ch)) break; } diff --git a/camel/camel-object-bag.c b/camel/camel-object-bag.c index d9b6b33..b4a9da6 100644 --- a/camel/camel-object-bag.c +++ b/camel/camel-object-bag.c @@ -317,7 +317,7 @@ camel_object_bag_reserve (CamelObjectBag *bag, /* If no such key exists in the bag, create a reservation. */ reservation = key_reservation_lookup (bag, key); if (reservation == NULL) { - reservation = key_reservation_new (bag, key); + key_reservation_new (bag, key); g_mutex_unlock (bag->mutex); return NULL; } diff --git a/camel/camel-provider.c b/camel/camel-provider.c index 43e5035..83dd13b 100644 --- a/camel/camel-provider.c +++ b/camel/camel-provider.c @@ -141,7 +141,8 @@ camel_provider_init (void) } p = strrchr (name, '.'); - strcpy (p, "." G_MODULE_SUFFIX); + if (p) + strcpy (p, "." G_MODULE_SUFFIX); m = g_malloc0 (sizeof (*m)); m->path = name; diff --git a/camel/camel-search-private.c b/camel/camel-search-private.c index 645a5a7..0d09cc3 100644 --- a/camel/camel-search-private.c +++ b/camel/camel-search-private.c @@ -148,7 +148,7 @@ soundexify (const gchar *sound, for (c = (guchar *) sound; *c && !isalpha (*c); c++); code[0] = toupper (*c); - memset (code + 1, '0', 3); + memset (code + 1, 0, 3); for (n = 1; *c && n < 5; c++) { guchar ch = soundex_table[*c]; @@ -211,7 +211,8 @@ camel_ustrstrcase (const gchar *haystack, if (strlen (haystack) == 0) return NULL; - puni = nuni = g_alloca (sizeof (gunichar) * strlen (needle)); + puni = nuni = g_alloca (sizeof (gunichar) * (strlen (needle) + 1)); + nuni[0] = 0; p = (const guchar *) needle; while ((u = camel_utf8_getc (&p))) diff --git a/camel/camel-search-sql-sexp.c b/camel/camel-search-sql-sexp.c index 07f6146..92d05da 100644 --- a/camel/camel-search-sql-sexp.c +++ b/camel/camel-search-sql-sexp.c @@ -729,7 +729,10 @@ camel_sexp_to_sql_sexp (const gchar *sql) } camel_sexp_input_text (sexp, sql, strlen (sql)); - camel_sexp_parse (sexp); + if (camel_sexp_parse (sexp)) { + g_object_unref (sexp); + return NULL; + } r = camel_sexp_eval (sexp); if (!r) { diff --git a/camel/camel-search-sql.c b/camel/camel-search-sql.c index 1bc8879..de5db79 100644 --- a/camel/camel-search-sql.c +++ b/camel/camel-search-sql.c @@ -313,7 +313,10 @@ camel_sexp_to_sql (const gchar *sexp) /* These should be normal tokens */ if (i >= G_N_ELEMENTS (elements)) { - Node *pnode = operands->data; + Node *pnode; + + g_return_val_if_fail (operands != NULL, NULL); + pnode = operands->data; node = g_new0 (Node, 1); node->token = g_strdup (token); @@ -353,9 +356,12 @@ camel_sexp_to_sql (const gchar *sexp) all = g_list_prepend (all, node); } else if (token == '+') { gchar *astr = NULL, *bstr = NULL; - Node *node, *pnode = operands->data; + Node *node, *pnode; gint lvl = 0, lval = 0; + g_return_val_if_fail (operands != NULL, NULL); + pnode = operands->data; + if (g_ascii_strcasecmp (pnode->token, "user-flag") == 0) { /* Colloct all after '+' and append them to one token. Go till you find ')' */ token = g_scanner_get_next_token (scanner); @@ -413,9 +419,12 @@ camel_sexp_to_sql (const gchar *sexp) level--; } else if (token == '-') { gchar *bstr = NULL; - Node *node, *pnode = operands->data; + Node *node, *pnode; gint lvl = 0, lval = 0; + g_return_val_if_fail (operands != NULL, NULL); + pnode = operands->data; + /* Colloct all after '+' and append them to one token. Go till you find ')' */ token = g_scanner_get_next_token (scanner); while (!g_scanner_eof (scanner) && lvl >=0 ) { @@ -471,7 +480,10 @@ camel_sexp_to_sql (const gchar *sexp) operators = g_list_prepend (operators, node); all = g_list_prepend (all, node); } else if (token == G_TOKEN_INT) { - Node *pnode = operands->data, *node; + Node *pnode, *node; + + g_return_val_if_fail (operands != NULL, NULL); + pnode = operands->data; node = g_new0 (Node, 1); node->token = g_strdup_printf ("%ld", scanner->value.v_int); @@ -664,7 +676,7 @@ camel_sexp_to_sql (const gchar *sexp) dbl = TRUE; } } - str = g_strdup_printf("(%s %c%s %s)", n2->exact_token, prefix ? prefix : ' ', opnode->exact_token, n1->exact_token); + str = g_strdup_printf("(%s %c%s %s)", n2->exact_token, prefix ? prefix : ' ', opnode ? opnode->exact_token : "", n1->exact_token); if (opnode) { free_node (opnode); diff --git a/camel/camel-session.c b/camel/camel-session.c index 0b183dd..daf8d8f 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -141,7 +141,7 @@ session_finish_job_cb (CamelSession *session, JobData *job_data; GError *error = NULL; - g_simple_async_result_propagate_error (simple, &error); + g_warn_if_fail (g_simple_async_result_propagate_error (simple, &error)); job_data = g_simple_async_result_get_op_res_gpointer (simple); g_signal_emit ( @@ -914,9 +914,6 @@ camel_session_get_service_by_url (CamelSession *session, if (provider == NULL) continue; - if (provider == NULL) - continue; - if (provider->url_equal == NULL) continue; diff --git a/camel/camel-store-summary.c b/camel/camel-store-summary.c index a1379d3..a17094d 100644 --- a/camel/camel-store-summary.c +++ b/camel/camel-store-summary.c @@ -178,10 +178,14 @@ store_summary_store_info_load (CamelStoreSummary *summary, io (printf ("Loading folder info\n")); - camel_file_util_decode_string (in, &info->path); - camel_file_util_decode_uint32 (in, &info->flags); - camel_file_util_decode_uint32 (in, &info->unread); - camel_file_util_decode_uint32 (in, &info->total); + if (camel_file_util_decode_string (in, &info->path) == -1 || + camel_file_util_decode_uint32 (in, &info->flags) == -1 || + camel_file_util_decode_uint32 (in, &info->unread) == -1 || + camel_file_util_decode_uint32 (in, &info->total) == -1) { + camel_store_summary_info_free (summary, info); + + return NULL; + } /* Ok, brown paper bag bug - prior to version 2 of the file, flags are * stored using the bit number, not the bit. Try to recover as best we can */ @@ -215,11 +219,11 @@ store_summary_store_info_save (CamelStoreSummary *summary, { io (printf ("Saving folder info\n")); - camel_file_util_encode_string ( - out, camel_store_info_path (summary, info)); - camel_file_util_encode_uint32 (out, info->flags); - camel_file_util_encode_uint32 (out, info->unread); - camel_file_util_encode_uint32 (out, info->total); + if (camel_file_util_encode_string (out, camel_store_info_path (summary, info)) == -1 || + camel_file_util_encode_uint32 (out, info->flags) == -1 || + camel_file_util_encode_uint32 (out, info->unread) == -1 || + camel_file_util_encode_uint32 (out, info->total) == -1) + return -1; return ferror (out); } diff --git a/camel/camel-store.c b/camel/camel-store.c index be38c1c..6f92de0 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -2794,7 +2794,7 @@ camel_store_rename_folder_sync (CamelStore *store, * We need to rename them atomically with renaming the actual * folder path. */ folders = camel_object_bag_list (store->folders); - for (i = 0; i < folders->len; i++) { + for (i = 0; folders && i < folders->len; i++) { const gchar *full_name; folder = folders->pdata[i]; diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c index 55fc9cf..7a4bf88 100644 --- a/camel/camel-tcp-stream-ssl.c +++ b/camel/camel-tcp-stream-ssl.c @@ -288,12 +288,12 @@ camel_certdb_nss_cert_get (CamelCertDB *certdb, filename = g_build_filename ( g_get_home_dir (), ".camel_certs", fingerprint, NULL); - g_file_get_contents (filename, &contents, &length, &error); - if (error != NULL) { + if (!g_file_get_contents (filename, &contents, &length, &error) || + error != NULL) { g_warning ( "Could not load cert %s: %s", - filename, error->message); - g_error_free (error); + filename, error ? error->message : "Unknown error"); + g_clear_error (&error); camel_cert_set_trust ( certdb, ccert, CAMEL_CERT_TRUST_UNKNOWN); diff --git a/camel/camel-text-index.c b/camel/camel-text-index.c index 7bac9c3..9cca48c 100644 --- a/camel/camel-text-index.c +++ b/camel/camel-text-index.c @@ -661,7 +661,7 @@ text_index_add_name (CamelIndex *idx, CAMEL_TEXT_INDEX_LOCK (idx, lock); /* if we're adding words, up the cache limits a lot */ - if (p->blocks) { + if (p->word_cache_limit < 8192) { p->blocks->block_cache_limit = 1024; p->word_cache_limit = 8192; } diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c index f8a6308..f3bd87a 100644 --- a/camel/camel-vee-folder.c +++ b/camel/camel-vee-folder.c @@ -391,7 +391,7 @@ folder_changed_change (CamelVeeFolder *vf, always_changed = g_ptr_array_new (); for (i = 0; i < changed->len; i++) { uid = changed->pdata[i]; - if (strlen (uid) + 9 > vuidlen) { + if (!vuid || strlen (uid) + 9 > vuidlen) { vuidlen = strlen (uid) + 64; vuid = g_realloc (vuid, vuidlen); } @@ -1709,7 +1709,7 @@ vee_folder_rebuild_folder (CamelVeeFolder *vee_folder, /* Since the source of a correlating vfolder has to be requeried in * full every time it changes, caching the results in the db is not * worth the effort. Thus, DB use is conditioned on !correlating. */ - gboolean correlating = expression_is_correlating (vee_folder->expression); + gboolean correlating = vee_folder->expression && expression_is_correlating (vee_folder->expression); if (vee_folder == folder_unmatched) return 0; diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index d1ab781..efbf764 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -1411,7 +1411,7 @@ get_matching (CamelFolder *folder, if (!list1) { for (flag = camel_message_info_user_flags (master_info); flag; flag = flag->next) { - if (flag->name && *flag->name) { + if (*flag->name) { count1++; list1 = g_list_prepend (list1, (gchar *) flag->name); } @@ -1421,7 +1421,7 @@ get_matching (CamelFolder *folder, } for (flag = camel_message_info_user_flags (info); flag; flag = flag->next) { - if (flag->name && *flag->name) { + if (*flag->name) { count2++; list2 = g_list_prepend (list2, (gchar *) flag->name); } @@ -2602,7 +2602,7 @@ imap_transfer_offline (CamelFolder *source, g_return_val_if_fail (mi != NULL, FALSE); message = camel_folder_get_message_sync ( - source, uid, cancellable, NULL); + source, uid, cancellable, &local_error); if (message) { camel_imap_summary_add_offline ( diff --git a/camel/providers/imap/camel-imap-search.c b/camel/providers/imap/camel-imap-search.c index bba2b07..b504352 100644 --- a/camel/providers/imap/camel-imap-search.c +++ b/camel/providers/imap/camel-imap-search.c @@ -297,7 +297,9 @@ load_match (CamelImapSearch *is, && header.termcount == 0) { d(printf(" found %d matches\n", header.matchcount)); g_array_set_size (mr->matches, header.matchcount); - camel_stream_read (stream, mr->matches->data, sizeof (guint32) * header.matchcount, NULL, NULL); + if (camel_stream_read (stream, mr->matches->data, sizeof (guint32) * header.matchcount, NULL, NULL) == -1) { + memset (&header, 0, sizeof (header)); + } } else { d(printf(" file format invalid/validity changed\n")); memset (&header, 0, sizeof (header)); diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 3320243..25c789a 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -3059,7 +3059,7 @@ imap_store_get_folder_info_sync (CamelStore *store, goto fail; if (top[0] == 0) { - pattern = g_alloca (2); + pattern = g_alloca (3); pattern[0] = '*'; pattern[1] = 0; i = 0; diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c index 51b5d04..7eed911 100644 --- a/camel/providers/imap/camel-imap-utils.c +++ b/camel/providers/imap/camel-imap-utils.c @@ -527,7 +527,7 @@ imap_create_flag_list (guint32 flags, /* FIXME: All the custom flags are sent to the server. Not just the changed ones */ flag = camel_message_info_user_flags (info); while (flag) { - if (flag->name && *flag->name) { + if (*flag->name) { name = rename_label_flag (flag->name, strlen (flag->name), FALSE); if (name && *name) @@ -629,7 +629,7 @@ imap_parse_flag_list (gchar **flag_list_p, *flag_list_p = flag_list; *flags_out = flags; - if (custom_flags_out && custom_flags->len) { + if (custom_flags_out && custom_flags && custom_flags->len) { *custom_flags_out = g_string_free (custom_flags, FALSE); } else if (custom_flags) g_string_free (custom_flags, TRUE); diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c index 353aa0b..7c38064 100644 --- a/camel/providers/imapx/camel-imapx-server.c +++ b/camel/providers/imapx/camel-imapx-server.c @@ -415,11 +415,11 @@ imapx_uidset_init (struct _uidset_state *ss, ss->limit = limit; } -gint +gboolean imapx_uidset_done (struct _uidset_state *ss, CamelIMAPXCommand *ic) { - gint ret = 0; + gint ret = FALSE; if (ss->last != 0 && ss->last != ss->start) { camel_imapx_command_add (ic, ":%d", ss->last); @@ -475,7 +475,8 @@ imapx_uidset_add (struct _uidset_state *ss, if ((ss->limit && ss->entries >= ss->limit) || (ss->total && ss->uids >= ss->total)) { e(ic->is->tagprefix, " done, %d entries, %d uids\n", ss->entries, ss->uids); - imapx_uidset_done (ss, ic); + if (!imapx_uidset_done (ss, ic)) + return -1; return 1; } @@ -2317,16 +2318,14 @@ imapx_command_select_done (CamelIMAPXServer *is, if (camel_imapx_command_set_error_if_failed (ic, &local_error)) { GQueue failed = G_QUEUE_INIT; GQueue trash = G_QUEUE_INIT; - GList *head, *link; + GList *link; c(is->tagprefix, "Select failed\n"); QUEUE_LOCK (is); - head = camel_imapx_command_queue_peek_head_link (is->queue); - if (is->select_pending) { - head = camel_imapx_command_queue_peek_head_link (is->queue); + GList *head = camel_imapx_command_queue_peek_head_link (is->queue); for (link = head; link != NULL; link = g_list_next (link)) { CamelIMAPXCommand *cw = link->data; @@ -2940,7 +2939,7 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is, } sasl = camel_sasl_new ("imap", mechanism, service); - if (sasl != NULL) { + if (sasl == NULL) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE, @@ -4169,12 +4168,11 @@ imapx_job_fetch_messages_start (CamelIMAPXJob *job, imapx_command_run_sync (is, ic, job->cancellable, &job->error); - if (ic->job->error == NULL) - camel_imapx_command_set_error_if_failed (ic, &ic->job->error); - - g_prefix_error ( - &ic->job->error, "%s: ", - _("Error while fetching messages")); + if (ic->job->error != NULL || camel_imapx_command_set_error_if_failed (ic, &ic->job->error)) { + g_prefix_error ( + &ic->job->error, "%s: ", + _("Error while fetching messages")); + } camel_imapx_command_unref (ic); } @@ -4293,6 +4291,7 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job, if (!need_rescan) { CamelIMAPXCommand *ic; + #if 0 if (is_selected) { /* We may not issue STATUS on the current folder. Use SELECT or NOOP instead. */ if (0 /* server needs SELECT not just NOOP */) { @@ -4311,7 +4310,9 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job, goto done; } } - } else { + } else + #endif + { if (is->cinfo->capa & IMAPX_CAPABILITY_CONDSTORE) ic = camel_imapx_command_new ( is, "STATUS", NULL, @@ -4327,12 +4328,11 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job, imapx_command_run_sync ( is, ic, job->cancellable, &job->error); - if (ic->job->error == NULL) - camel_imapx_command_set_error_if_failed (ic, &ic->job->error); - - g_prefix_error ( - &ic->job->error, "%s: ", - _("Error refreshing folder")); + if (ic->job->error != NULL || camel_imapx_command_set_error_if_failed (ic, &ic->job->error)) { + g_prefix_error ( + &ic->job->error, "%s: ", + _("Error refreshing folder")); + } if (ic->job->error != NULL) { camel_imapx_command_unref (ic); @@ -4362,13 +4362,12 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job, imapx_command_run_sync (is, ic, job->cancellable, &job->error); - if (ic->job->error == NULL) - camel_imapx_command_set_error_if_failed (ic, &ic->job->error); + if (ic->job->error != NULL || camel_imapx_command_set_error_if_failed (ic, &ic->job->error)) { + g_prefix_error ( + &ic->job->error, "%s: ", + _("Error refreshing folder")); + } - g_prefix_error ( - &ic->job->error, "%s: ", - _("Error refreshing folder")); - if (ic->job->error != NULL) { camel_imapx_command_unref (ic); goto done; @@ -5019,7 +5018,7 @@ imapx_job_sync_changes_start (CamelIMAPXJob *job, } send = imapx_uidset_add (&ss, ic, camel_message_info_uid (info)); } - if (send || (i == uids->len - 1 && imapx_uidset_done (&ss, ic))) { + if (send == 1 || (i == uids->len - 1 && imapx_uidset_done (&ss, ic))) { job->commands++; camel_imapx_command_add (ic, " %tFLAGS.SILENT (%t)", on?"+":"-", flags_table[j].name); imapx_command_queue (is, ic); @@ -5056,7 +5055,7 @@ imapx_job_sync_changes_start (CamelIMAPXJob *job, ic->pri = job->pri; } - if (imapx_uidset_add (&ss, ic, camel_message_info_uid (info)) + if (imapx_uidset_add (&ss, ic, camel_message_info_uid (info)) == 1 || (i == c->infos->len - 1 && imapx_uidset_done (&ss, ic))) { job->commands++; camel_imapx_command_add (ic, " %tFLAGS.SILENT (%t)", on?"+":"-", c->name); @@ -5881,7 +5880,7 @@ imapx_server_sync_changes (CamelIMAPXServer *is, if (uflags) { if (suflags) res = strcmp (uflags->name, suflags->name); - else if (uflags->name && *uflags->name) + else if (*uflags->name) res = -1; else { uflags = uflags->next; diff --git a/camel/providers/imapx/camel-imapx-store-summary.c b/camel/providers/imapx/camel-imapx-store-summary.c index c764106..8a8142e 100644 --- a/camel/providers/imapx/camel-imapx-store-summary.c +++ b/camel/providers/imapx/camel-imapx-store-summary.c @@ -666,5 +666,5 @@ camel_imapx_store_summary_set_namespaces (CamelIMAPXStoreSummary *summary, { if (summary->namespaces) camel_imapx_namespace_list_clear (summary->namespaces); - summary->namespaces = camel_imapx_namespace_list_copy (summary->namespaces); + summary->namespaces = camel_imapx_namespace_list_copy (nsl); } diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c index a7a0825..776f615 100644 --- a/camel/providers/imapx/camel-imapx-utils.c +++ b/camel/providers/imapx/camel-imapx-utils.c @@ -885,9 +885,8 @@ imapx_parse_address_list (CamelIMAPXStream *is, tok = camel_imapx_stream_token (is, &token, &len, cancellable, &local_error); if (tok == '(') { + struct _camel_header_address *addr, *group = NULL; while (1) { - struct _camel_header_address *addr, *group = NULL; - /* address ::= "(" addr_name SPACE addr_adl SPACE addr_mailbox * SPACE addr_host ")" */ tok = camel_imapx_stream_token (is, &token, &len, cancellable, &local_error); @@ -930,7 +929,7 @@ imapx_parse_address_list (CamelIMAPXStream *is, group = addr; } } else { - addr->v.addr = g_strdup_printf("%s%s%s", mbox? mbox:"", host?"@":"", host?(gchar *)host:""); + addr->v.addr = g_strdup_printf ("%s@%s", mbox? mbox :"", (const gchar *) host); g_free (mbox); d(is->tagprefix, "adding address '%s'\n", addr->v.addr); if (group != NULL) @@ -1082,7 +1081,6 @@ imapx_parse_body (CamelIMAPXStream *is, struct _CamelMessageContentInfo * cinfo = NULL; struct _CamelMessageContentInfo *subinfo, *last; struct _CamelContentDisposition * dinfo = NULL; - struct _CamelMessageInfo * minfo = NULL; GError *local_error = NULL; /* body ::= "(" body_type_1part / body_type_mpart ")" */ @@ -1161,6 +1159,8 @@ imapx_parse_body (CamelIMAPXStream *is, tok = camel_imapx_stream_token (is, &token, &len, cancellable, &local_error); camel_imapx_stream_ungettoken (is, tok, token, len); if (tok == '(') { + struct _CamelMessageInfo * minfo = NULL; + /* what do we do with the envelope?? */ minfo = imapx_parse_envelope (is, cancellable, &local_error); /* what do we do with the message content info?? */ @@ -1220,8 +1220,6 @@ imapx_parse_body (CamelIMAPXStream *is, imapx_free_body (cinfo); if (dinfo) camel_content_disposition_unref (dinfo); - if (minfo) - camel_message_info_free (minfo); return NULL; } diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c index a8adf29..dcb0887 100644 --- a/camel/providers/local/camel-maildir-folder.c +++ b/camel/providers/local/camel-maildir-folder.c @@ -163,7 +163,7 @@ maildir_folder_append_message_sync (CamelFolder *folder, d(printf("Appending message\n")); /* If we can't lock, don't do anything */ - if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) + if (!lf || camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) return FALSE; /* add it to the summary/assign the uid, etc */ @@ -239,7 +239,7 @@ maildir_folder_append_message_sync (CamelFolder *folder, check_changed: camel_local_folder_unlock (lf); - if (lf && camel_folder_change_info_changed (lf->changes)) { + if (camel_folder_change_info_changed (lf->changes)) { camel_folder_changed (folder, lf->changes); camel_folder_change_info_clear (lf->changes); } @@ -260,7 +260,7 @@ maildir_folder_get_message_sync (CamelFolder *folder, d(printf("getting message: %s\n", uid)); - if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) + if (!lf || camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) return NULL; name = maildir_folder_get_filename (folder, uid, error); diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c index 1ba2790..2d2065f 100644 --- a/camel/providers/local/camel-mbox-summary.c +++ b/camel/providers/local/camel-mbox-summary.c @@ -722,7 +722,6 @@ mbox_summary_sync_full (CamelMboxSummary *mbs, g_strerror (errno)); goto error; } - tmpname = NULL; camel_operation_pop_message (cancellable); camel_folder_summary_unlock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK); @@ -735,8 +734,7 @@ mbox_summary_sync_full (CamelMboxSummary *mbs, if (fdout != -1) close (fdout); - if (tmpname) - g_unlink (tmpname); + g_unlink (tmpname); camel_operation_pop_message (cancellable); camel_folder_summary_unlock (s, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK); @@ -1153,7 +1151,7 @@ camel_mbox_summary_sync_mbox (CamelMboxSummary *cls, ((CamelMessageInfo *) info)->dirty = TRUE; fromline = camel_mime_parser_from_line (mp); d(printf("Saving %s:%d\n", camel_message_info_uid(info), info->frompos)); - write (fdout, fromline, strlen (fromline)); + g_warn_if_fail (write (fdout, fromline, strlen (fromline)) != -1); } if (info && info->info.info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV | CAMEL_MESSAGE_FOLDER_FLAGGED)) { @@ -1264,9 +1262,8 @@ camel_mbox_summary_sync_mbox (CamelMboxSummary *cls, return 0; error: g_free (xevnew); + g_object_unref (mp); - if (mp) - g_object_unref (mp); if (info) camel_message_info_free ((CamelMessageInfo *) info); diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c index 53be12a..c9caf21 100644 --- a/camel/providers/local/camel-mh-folder.c +++ b/camel/providers/local/camel-mh-folder.c @@ -71,7 +71,7 @@ mh_folder_append_message_sync (CamelFolder *folder, d(printf("Appending message\n")); /* If we can't lock, don't do anything */ - if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) + if (!lf || camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) return FALSE; /* add it to the summary/assign the uid, etc */ @@ -128,7 +128,7 @@ mh_folder_append_message_sync (CamelFolder *folder, check_changed: camel_local_folder_unlock (lf); - if (lf && camel_folder_change_info_changed (lf->changes)) { + if (camel_folder_change_info_changed (lf->changes)) { camel_folder_changed (folder, lf->changes); camel_folder_change_info_clear (lf->changes); } @@ -150,7 +150,7 @@ mh_folder_get_message_sync (CamelFolder *folder, d(printf("getting message: %s\n", uid)); - if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) + if (!lf || camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) return NULL; /* get the message summary info */ @@ -192,7 +192,7 @@ mh_folder_get_message_sync (CamelFolder *folder, camel_local_folder_unlock (lf); - if (lf && camel_folder_change_info_changed (lf->changes)) { + if (camel_folder_change_info_changed (lf->changes)) { camel_folder_changed (folder, lf->changes); camel_folder_change_info_clear (lf->changes); } diff --git a/camel/providers/local/camel-mh-summary.c b/camel/providers/local/camel-mh-summary.c index 2fa2c41..7e9589f 100644 --- a/camel/providers/local/camel-mh-summary.c +++ b/camel/providers/local/camel-mh-summary.c @@ -129,8 +129,6 @@ mh_summary_next_uid_string (CamelFolderSummary *s) } else { /* else scan for one - and create it too, to make sure */ do { - if (fd != -1) - close (fd); uid = camel_folder_summary_next_uid (s); name = g_strdup_printf("%s/%u", cls->folder_path, uid); /* O_EXCL isn't guaranteed, sigh. Oh well, bad luck, mh has problems anyway */ diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c index 38fcf3e..29d7cc9 100644 --- a/camel/providers/local/camel-spool-store.c +++ b/camel/providers/local/camel-spool-store.c @@ -499,13 +499,15 @@ spool_store_get_folder_sync (CamelStore *store, _("Folder '%s' does not exist."), folder_name); } else { - if (creat (name, 0600) == -1) { + gint fd = creat (name, 0600); + if (fd == -1) { g_set_error ( error, G_IO_ERROR, g_io_error_from_errno (errno), _("Could not create folder '%s':\n%s"), folder_name, g_strerror (errno)); } else { + close (fd); folder = camel_spool_folder_new ( store, folder_name, flags, cancellable, error); diff --git a/camel/providers/nntp/camel-nntp-store-summary.c b/camel/providers/nntp/camel-nntp-store-summary.c index 4f0c3f3..368b4f5 100644 --- a/camel/providers/nntp/camel-nntp-store-summary.c +++ b/camel/providers/nntp/camel-nntp-store-summary.c @@ -297,9 +297,7 @@ summary_header_load (CamelStoreSummary *s, if (fread (is->last_newslist, 1, NNTP_DATE_SIZE, in) < NNTP_DATE_SIZE) return -1; - camel_file_util_decode_fixed_int32 (in, &nil); - - return 0; + return camel_file_util_decode_fixed_int32 (in, &nil); } static gint diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index 77773a8..351eb72 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -738,7 +738,8 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, short_folder_names = camel_nntp_settings_get_short_folder_names ( CAMEL_NNTP_SETTINGS (settings)); - for (i = 0;(si = camel_store_summary_index ((CamelStoreSummary *) store->summary, i)); i++) { + for (i = 0; i < camel_store_summary_count ((CamelStoreSummary *) store->summary); i++) { + si = camel_store_summary_index ((CamelStoreSummary *) store->summary, i); if (si == NULL) continue; @@ -757,10 +758,11 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, CamelFolderChangeInfo *changes = NULL; camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); - camel_nntp_command (store, cancellable, NULL, folder, &line, NULL); - if (camel_folder_change_info_changed (folder->changes)) { - changes = folder->changes; - folder->changes = camel_folder_change_info_new (); + if (camel_nntp_command (store, cancellable, NULL, folder, &line, NULL) != -1) { + if (camel_folder_change_info_changed (folder->changes)) { + changes = folder->changes; + folder->changes = camel_folder_change_info_new (); + } } camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK); if (changes) { @@ -913,8 +915,11 @@ nntp_store_get_cached_folder_info (CamelNNTPStore *store, if (!last || strncmp (si->path, last->full_name, strlen (last->full_name)) != 0 || si->path[strlen (last->full_name)] != '.') { + gchar *dot; tmpname = g_strdup (si->path); - *(strchr(tmpname + toplen, '.')) = '\0'; + dot = strchr(tmpname + toplen, '.'); + if (dot) + *dot = '\0'; fi = nntp_folder_info_from_name (store, FALSE, tmpname); if (!fi) continue; @@ -1740,7 +1745,7 @@ camel_nntp_command (CamelNNTPStore *store, return -1; /* Check for unprocessed data, !*/ - if (store->stream->mode == CAMEL_NNTP_STREAM_DATA) { + if (store->stream && store->stream->mode == CAMEL_NNTP_STREAM_DATA) { g_warning("Unprocessed data left in stream, flushing"); while (camel_nntp_stream_getd (store->stream, (guchar **) &p, &u, cancellable, error) > 0) ; diff --git a/camel/providers/nntp/camel-nntp-stream.c b/camel/providers/nntp/camel-nntp-stream.c index 98d1a4e..bbb4127 100644 --- a/camel/providers/nntp/camel-nntp-stream.c +++ b/camel/providers/nntp/camel-nntp-stream.c @@ -282,6 +282,10 @@ camel_nntp_stream_line (CamelNNTPStream *is, gint newlen, oldlen; guchar *e; + g_return_val_if_fail (is != NULL, -1); + g_return_val_if_fail (data != NULL, -1); + g_return_val_if_fail (len != NULL, -1); + if (is->mode == CAMEL_NNTP_STREAM_EOD) { *data = is->linebuf; *len = 0; @@ -368,6 +372,10 @@ camel_nntp_stream_gets (CamelNNTPStream *is, gint max; guchar *end; + g_return_val_if_fail (is != NULL, -1); + g_return_val_if_fail (start != NULL, -1); + g_return_val_if_fail (len != NULL, -1); + *len = 0; max = is->end - is->ptr; @@ -394,6 +402,8 @@ void camel_nntp_stream_set_mode (CamelNNTPStream *is, camel_nntp_stream_mode_t mode) { + g_return_if_fail (is != NULL); + is->mode = mode; } @@ -408,6 +418,10 @@ camel_nntp_stream_getd (CamelNNTPStream *is, guchar *p, *e, *s; gint state; + g_return_val_if_fail (is != NULL, -1); + g_return_val_if_fail (start != NULL, -1); + g_return_val_if_fail (len != NULL, -1); + *len = 0; if (is->mode == CAMEL_NNTP_STREAM_EOD) diff --git a/camel/providers/pop3/camel-pop3-engine.c b/camel/providers/pop3/camel-pop3-engine.c index 686be68..86c0d41 100644 --- a/camel/providers/pop3/camel-pop3-engine.c +++ b/camel/providers/pop3/camel-pop3-engine.c @@ -426,6 +426,7 @@ camel_pop3_engine_command_new (CamelPOP3Engine *pe, va_start (ap, fmt); pc->data = g_strdup_vprintf (fmt, ap); + va_end (ap); pc->state = CAMEL_POP3_COMMAND_IDLE; /* TODO: what about write errors? */ diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c index a0c10cf..dbaa785 100644 --- a/camel/providers/pop3/camel-pop3-folder.c +++ b/camel/providers/pop3/camel-pop3-folder.c @@ -365,7 +365,6 @@ static void pop3_folder_dispose (GObject *object) { CamelPOP3Folder *pop3_folder = CAMEL_POP3_FOLDER (object); - CamelPOP3FolderInfo **fi = (CamelPOP3FolderInfo **) pop3_folder->uids->pdata; CamelPOP3Store *pop3_store = NULL; CamelStore *parent_store; @@ -375,6 +374,7 @@ pop3_folder_dispose (GObject *object) if (pop3_folder->uids) { gint i; + CamelPOP3FolderInfo **fi = (CamelPOP3FolderInfo **) pop3_folder->uids->pdata; gboolean is_online = camel_service_get_connection_status (CAMEL_SERVICE (parent_store)) == CAMEL_SERVICE_CONNECTED; for (i = 0; i < pop3_folder->uids->len; i++, fi++) { diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index 9ae93fd..c97854f 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -101,7 +101,6 @@ connect_to_server (CamelService *service, gboolean success = TRUE; gchar *host; guint32 flags = 0; - gint clean_quit = TRUE; gint ret; settings = camel_service_get_settings (service); @@ -148,9 +147,6 @@ connect_to_server (CamelService *service, goto exit; } - /* as soon as we send a STLS command, all hope is lost of a clean QUIT if problems arise */ - clean_quit = FALSE; - if (!(store->engine->capa & CAMEL_POP3_CAP_STLS)) { g_set_error ( error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, @@ -200,13 +196,14 @@ connect_to_server (CamelService *service, goto exit; stls_exception: - if (clean_quit) { - /* try to disconnect cleanly */ + /* as soon as we send a STLS command, all hope is lost of a clean QUIT if problems arise */ + /* if (clean_quit) { + / * try to disconnect cleanly * / pc = camel_pop3_engine_command_new (store->engine, 0, NULL, NULL, cancellable, NULL, "QUIT\r\n"); while (camel_pop3_engine_iterate (store->engine, NULL, cancellable, NULL) > 0) ; camel_pop3_engine_command_free (store->engine, pc); - } + }*/ g_object_unref (store->engine); g_object_unref (tcp_stream); @@ -801,7 +798,7 @@ camel_pop3_store_expunge (CamelPOP3Store *store, { CamelPOP3Command *pc; - if (!camel_service_get_connection_status (CAMEL_SERVICE (store)) == CAMEL_SERVICE_CONNECTED) { + if (camel_service_get_connection_status (CAMEL_SERVICE (store)) != CAMEL_SERVICE_CONNECTED) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE, diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c index 3a836fd..507cc81 100644 --- a/camel/providers/sendmail/camel-sendmail-transport.c +++ b/camel/providers/sendmail/camel-sendmail-transport.c @@ -153,9 +153,11 @@ sendmail_send_to_sync (CamelTransport *transport, /* Child process */ nullfd = open ("/dev/null", O_RDWR); dup2 (fd[0], STDIN_FILENO); - /*dup2 (nullfd, STDOUT_FILENO); - dup2 (nullfd, STDERR_FILENO);*/ - close (nullfd); + if (nullfd != -1) { + /*dup2 (nullfd, STDOUT_FILENO); + dup2 (nullfd, STDERR_FILENO);*/ + close (nullfd); + } close (fd[1]); execv (SENDMAIL_PATH, (gchar **) argv); diff --git a/libedataserver/e-gdbus-templates.c b/libedataserver/e-gdbus-templates.c index 5e8125a..fe31eb8 100644 --- a/libedataserver/e-gdbus-templates.c +++ b/libedataserver/e-gdbus-templates.c @@ -594,6 +594,7 @@ e_gdbus_proxy_emit_signal (GDBusProxy *proxy, g_variant_get (parameters, "(u&s&su)", &arg_opid, &dbus_error_name, &dbus_error_message, &arg_uint); break; default: + /* fix below too, if this is reached */ g_warning ("%s: Unknown E_GDBUS_TYPE %x", G_STRFUNC, signal_type); return; } @@ -618,9 +619,6 @@ e_gdbus_proxy_emit_signal (GDBusProxy *proxy, case E_GDBUS_TYPE_UINT: g_signal_emit (proxy, signal_id, 0, arg_opid, arg_error, arg_uint); break; - default: - g_warning ("%s: Unknown E_GDBUS_TYPE %x", G_STRFUNC, signal_type); - break; } if (arg_error) diff --git a/libedataserver/e-proxy.c b/libedataserver/e-proxy.c index 709a518..45454df 100644 --- a/libedataserver/e-proxy.c +++ b/libedataserver/e-proxy.c @@ -681,12 +681,11 @@ update_proxy_uri (const gchar *uri, /* here can be only http or https and nothing else */ is_https = g_str_has_prefix (uri, "https://"); - res = g_strdup_printf ("%s://%s%s%s%s%s", + res = g_strdup_printf ("%s://%s%s%s@%s", is_https ? "https" : "http", - user ? user : "", + user, pw ? ":" : "", pw ? pw : "", - (user || pw) ? "@" : "", uri + strlen ("http://") + (is_https ? 1 : 0)); g_free (user); diff --git a/libedataserverui/e-name-selector-entry.c b/libedataserverui/e-name-selector-entry.c index 27caccc..70a2c1e 100644 --- a/libedataserverui/e-name-selector-entry.c +++ b/libedataserverui/e-name-selector-entry.c @@ -2434,7 +2434,7 @@ editor_closed_cb (GtkWidget *editor, if (book_client) { contact = NULL; - e_book_client_get_contact_sync (book_client, contact_uid, &contact, NULL, NULL); + g_warn_if_fail (e_book_client_get_contact_sync (book_client, contact_uid, &contact, NULL, NULL)); email_num = e_destination_get_email_num (destination); e_destination_set_contact (destination, contact, email_num); e_destination_set_client (destination, book_client); diff --git a/libedataserverui/e-source-combo-box.c b/libedataserverui/e-source-combo-box.c index af45ee6..89fdad2 100644 --- a/libedataserverui/e-source-combo-box.c +++ b/libedataserverui/e-source-combo-box.c @@ -100,7 +100,7 @@ source_list_changed_cb (ESourceList *source_list, * hardly a performance issue here since source lists * are short. */ - gtk_tree_model_get_iter_first (model, &iter); + iter_valid = gtk_tree_model_get_iter_first (model, &iter); for (groups = e_source_list_peek_groups (source_list); groups != NULL; groups = groups->next) { @@ -110,7 +110,7 @@ source_list_changed_cb (ESourceList *source_list, continue; name = e_source_group_peek_name (groups->data); - if (!gtk_list_store_iter_is_valid (store, &iter)) + if (!iter_valid) gtk_list_store_append (store, &iter); gtk_list_store_set ( store, &iter, @@ -119,7 +119,7 @@ source_list_changed_cb (ESourceList *source_list, COLUMN_SENSITIVE, FALSE, COLUMN_SOURCE, groups->data, -1); - gtk_tree_model_iter_next (model, &iter); + iter_valid = gtk_tree_model_iter_next (model, &iter); sources = e_source_group_peek_sources (groups->data); @@ -141,7 +141,7 @@ source_list_changed_cb (ESourceList *source_list, visible = TRUE; } - if (!gtk_list_store_iter_is_valid (store, &iter)) + if (!iter_valid) gtk_list_store_append (store, &iter); gtk_list_store_set ( store, &iter, @@ -157,7 +157,7 @@ source_list_changed_cb (ESourceList *source_list, priv->uid_index, g_strdup (uid), gtk_tree_row_reference_new (model, path)); gtk_tree_path_free (path); - gtk_tree_model_iter_next (model, &iter); + iter_valid = gtk_tree_model_iter_next (model, &iter); g_free (indented_name); } diff --git a/libedataserverui/e-tree-model-generator.c b/libedataserverui/e-tree-model-generator.c index 9269d17..b870d85 100644 --- a/libedataserverui/e-tree-model-generator.c +++ b/libedataserverui/e-tree-model-generator.c @@ -329,6 +329,8 @@ child_offset_to_generated_offset (GArray *group, gint accum_offset = 0; gint i; + g_return_val_if_fail (group != NULL, -1); + for (i = 0; i < group->len && i < offset; i++) { Node *node = &g_array_index (group, Node, i); @@ -894,6 +896,8 @@ e_tree_model_generator_convert_child_iter_to_iter (ETreeModelGenerator *tree_mod } } + g_return_if_fail (group != NULL); + index = child_offset_to_generated_offset (group, index); ITER_SET (tree_model_generator, generator_iter, group, index); gtk_tree_path_free (path); @@ -1095,10 +1099,10 @@ e_tree_model_generator_get_path (GtkTreeModel *tree_model, group = node->parent_group; index = node->parent_index; - generated_index = child_offset_to_generated_offset (group, index); - - if (group) + if (group) { + generated_index = child_offset_to_generated_offset (group, index); gtk_tree_path_prepend_index (path, generated_index); + } } return path; @@ -1190,7 +1194,7 @@ e_tree_model_generator_iter_has_child (GtkTreeModel *tree_model, ITER_GET (iter, &group, &index); index = generated_offset_to_child_offset (group, index, NULL); - if (!index < 0) + if (index < 0) return FALSE; node = &g_array_index (group, Node, index); diff --git a/tests/libebook/client/client-test-utils.c b/tests/libebook/client/client-test-utils.c index 760217b..fd73dc6 100644 --- a/tests/libebook/client/client-test-utils.c +++ b/tests/libebook/client/client-test-utils.c @@ -257,8 +257,10 @@ foreach_configured_source_async_start (ESource **source) if (!async_data->current_group) { gpointer ad = async_data; - foreach_configured_source_async_next (&ad, source); - return ad; + if (foreach_configured_source_async_next (&ad, source)) + return ad; + + return NULL; } async_data->current_source = e_source_group_peek_sources (async_data->current_group->data); diff --git a/tests/libebook/client/test-client-photo-is-uri.c b/tests/libebook/client/test-client-photo-is-uri.c index 430d00d..8dd8019 100644 --- a/tests/libebook/client/test-client-photo-is-uri.c +++ b/tests/libebook/client/test-client-photo-is-uri.c @@ -250,7 +250,6 @@ add_contact_inline (EBookClient *book) { EContact *contact; EContactPhoto *photo; - GError *error = NULL; guchar *data; gsize length = 0; @@ -269,7 +268,7 @@ add_contact_inline (EBookClient *book) e_contact_set (contact, E_CONTACT_FULL_NAME, "Micheal Jackson"); if (!add_contact_verify (book, contact)) - g_error ("Failed to add contact: %s", error->message); + g_error ("Failed to add contact"); micheal_jackson_uid = e_contact_get (contact, E_CONTACT_UID); } @@ -279,7 +278,6 @@ add_contact_uri (EBookClient *book) { EContact *contact; EContactPhoto *photo; - GError *error = NULL; contact = e_contact_new (); @@ -292,7 +290,7 @@ add_contact_uri (EBookClient *book) e_contact_set (contact, E_CONTACT_FULL_NAME, "James Brown"); if (!add_contact_verify (book, contact)) - g_error ("Failed to add contact: %s", error->message); + g_error ("Failed to add contact"); james_brown_uid = e_contact_get (contact, E_CONTACT_UID); } diff --git a/tests/libebook/client/test-client-suppress-notifications.c b/tests/libebook/client/test-client-suppress-notifications.c index 781f3d0..e87bdf6 100644 --- a/tests/libebook/client/test-client-suppress-notifications.c +++ b/tests/libebook/client/test-client-suppress-notifications.c @@ -13,7 +13,7 @@ static gboolean loading_view; static void add_contact (EBookClient *book_client) { - add_contact_from_test_case_verify (book_client, "name-only", NULL); + g_return_if_fail (add_contact_from_test_case_verify (book_client, "name-only", NULL)); } static gboolean diff --git a/tests/libebook/ebook-test-utils.c b/tests/libebook/ebook-test-utils.c index 7b9c074..5e3ed8e 100644 --- a/tests/libebook/ebook-test-utils.c +++ b/tests/libebook/ebook-test-utils.c @@ -142,10 +142,10 @@ add_contact_cb (EBook *book, test_print ("successfully asynchronously added the contact " "addressbook\n"); - if (closure) { + if (closure->cb) (*closure->cb) (closure); - g_free (closure); - } + + g_free (closure); } void @@ -197,10 +197,10 @@ commit_contact_cb (EBook *book, test_print ("successfully asynchronously committed the contact to the " "addressbook\n"); - if (closure) { + if (closure->cb) (*closure->cb) (closure); - g_free (closure); - } + + g_free (closure); } void @@ -258,10 +258,10 @@ get_contact_cb (EBook *book, test_print ("successfully asynchronously retrieved the contact '%s'\n", uid); - if (closure) { + if (closure->cb) (*closure->cb) (closure); - g_free (closure); - } + + g_free (closure); } void @@ -317,10 +317,10 @@ get_required_fields_cb (EBook *book, test_print ("successfully asynchronously retrieved the required fields\n"); - if (closure) { + if (closure->cb) (*closure->cb) (closure); - g_free (closure); - } + + g_free (closure); } void @@ -394,10 +394,9 @@ get_supported_auth_methods_cb (EBook *book, test_print ("successfully asynchronously retrieved the supported auth " "methods\n"); - if (closure) { + if (closure->cb) (*closure->cb) (closure); - g_free (closure); - } + g_free (closure); } void @@ -452,10 +451,9 @@ get_supported_fields_cb (EBook *book, test_print ("successfully asynchronously retrieved the supported fields\n"); - if (closure) { + if (closure->cb) (*closure->cb) (closure); - g_free (closure); - } + g_free (closure); } void @@ -505,10 +503,10 @@ remove_contact_cb (EBook *book, test_print ("successfully asynchronously removed the contact\n"); - if (closure) { + if (closure->cb) (*closure->cb) (closure); - g_free (closure); - } + + g_free (closure); } void @@ -543,10 +541,10 @@ remove_contact_by_id_cb (EBook *book, test_print ("successfully asynchronously removed the contact by id\n"); - if (closure) { + if (closure->cb) (*closure->cb) (closure); - g_free (closure); - } + + g_free (closure); } void @@ -597,10 +595,10 @@ remove_contacts_cb (EBook *book, test_print ("successfully asynchronously removed the contacts\n"); - if (closure) { + if (closure->cb) (*closure->cb) (closure); - g_free (closure); - } + + g_free (closure); } void @@ -710,7 +708,7 @@ remove_cb (EBook *book, test_print ("successfully asynchronously removed the temporary " "addressbook\n"); - if (closure) + if (closure->cb) (*closure->cb) (closure); } @@ -763,7 +761,7 @@ get_book_view_cb (EBook *book, closure->view = view; test_print ("successfully asynchronously retrieved the book view\n"); - if (closure) + if (closure->cb) (*closure->cb) (closure); } diff --git a/tests/libebook/test-categories.c b/tests/libebook/test-categories.c index 49563ea..d65b217 100644 --- a/tests/libebook/test-categories.c +++ b/tests/libebook/test-categories.c @@ -22,8 +22,6 @@ main (gint argc, e_contact_set (contact, E_CONTACT_CATEGORY_LIST, category_list); - category_list = e_contact_get (contact, E_CONTACT_CATEGORY_LIST); - printf ("vcard = \n%s\n", e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30)); categories = e_contact_get (contact, E_CONTACT_CATEGORIES); diff --git a/tests/libebook/vcard/dump-vcard.c b/tests/libebook/vcard/dump-vcard.c index 2a9eb4c..1b8bdbe 100644 --- a/tests/libebook/vcard/dump-vcard.c +++ b/tests/libebook/vcard/dump-vcard.c @@ -20,6 +20,10 @@ main (gint argc, g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS); fp = fopen (argv[1], "r"); + if (fp == NULL) { + g_warning ("Faile to open vCard file '%s'", argv[1]); + return 1; + } while (!feof (fp)) { gchar buf[1024]; diff --git a/tests/libecal/ecal-test-utils.c b/tests/libecal/ecal-test-utils.c index a6b53fd..c3e7f55 100644 --- a/tests/libecal/ecal-test-utils.c +++ b/tests/libecal/ecal-test-utils.c @@ -127,7 +127,7 @@ open_ex_cb (ECal *cal, test_print ("successfully asynchronously removed the temporary " "calendar\n"); - if (closure) + if (closure->cb) (*closure->cb) (closure); g_signal_handlers_disconnect_by_func (cal, open_ex_cb, closure); @@ -486,7 +486,7 @@ cal_set_mode_cb (ECal *cal, closure->mode = mode; test_print ("successfully set the calendar mode to %d\n", mode); - if (closure) + if (closure->cb) (*closure->cb) (closure); g_signal_handlers_disconnect_by_func (cal, cal_set_mode_cb, closure); diff --git a/tests/libecal/test-ecal.c b/tests/libecal/test-ecal.c index 63633e7..73509af 100644 --- a/tests/libecal/test-ecal.c +++ b/tests/libecal/test-ecal.c @@ -51,9 +51,10 @@ cl_printf (ECal *client, { va_list args; - va_start (args, format); - if ( client != client1) + if (client != client1) return; + + va_start (args, format); printf ("Client %s: ", "Test"); vprintf (format, args); va_end (args); diff --git a/tests/libedataserverui/test-contact-store.c b/tests/libedataserverui/test-contact-store.c index 7ac189d..4b1566d 100644 --- a/tests/libedataserverui/test-contact-store.c +++ b/tests/libedataserverui/test-contact-store.c @@ -96,7 +96,7 @@ start_test (const gchar *gconf_path) gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view); book_client = e_book_client_new_default (NULL); - e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, NULL); + g_warn_if_fail (e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, NULL)); e_contact_store_add_client (contact_store, book_client); g_object_unref (book_client);