[libgdata] [core] Tidy up preconditions



commit ca20862ec3235e25763317ebdea60146327ecd14
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Apr 10 18:13:52 2010 +0100

    [core] Tidy up preconditions
    
    Tidy up the public API preconditions and ensure they're present for all
    public (and most semi-public) functions.

 gdata/atom/gdata-author.c                          |    3 +
 gdata/atom/gdata-category.c                        |    3 +
 gdata/atom/gdata-generator.c                       |    3 +
 gdata/atom/gdata-link.c                            |    3 +
 gdata/gcontact/gdata-gcontact-calendar.c           |    3 +
 gdata/gcontact/gdata-gcontact-external-id.c        |    3 +
 gdata/gcontact/gdata-gcontact-language.c           |    3 +
 gdata/gcontact/gdata-gcontact-website.c            |    3 +
 gdata/gd/gdata-gd-email-address.c                  |    3 +
 gdata/gd/gdata-gd-im-address.c                     |    4 ++
 gdata/gd/gdata-gd-name.c                           |    5 ++
 gdata/gd/gdata-gd-organization.c                   |    3 +
 gdata/gd/gdata-gd-phone-number.c                   |    4 ++
 gdata/gd/gdata-gd-postal-address.c                 |    3 +
 gdata/gd/gdata-gd-reminder.c                       |    4 ++
 gdata/gd/gdata-gd-when.c                           |    3 +
 gdata/gd/gdata-gd-where.c                          |    3 +
 gdata/gd/gdata-gd-who.c                            |    3 +
 gdata/gdata-access-handler.c                       |    6 +-
 gdata/gdata-buffer.c                               |   17 ++++++-
 gdata/gdata-entry.c                                |    4 +-
 gdata/gdata-feed.c                                 |    2 +-
 gdata/gdata-parsable.c                             |   11 +++++
 gdata/gdata-query.c                                |    7 +++
 gdata/gdata-service.c                              |    4 --
 gdata/gdata-upload-stream.c                        |    1 +
 gdata/media/gdata-media-group.c                    |    7 +++
 gdata/services/calendar/gdata-calendar-calendar.c  |   40 +++++++++---------
 gdata/services/calendar/gdata-calendar-event.c     |   46 ++++++++++----------
 gdata/services/calendar/gdata-calendar-service.c   |   28 ++++++++++++
 gdata/services/contacts/gdata-contacts-service.c   |   14 ++++++
 .../documents/gdata-documents-presentation.c       |    2 +
 gdata/services/documents/gdata-documents-service.c |   12 +++++
 .../documents/gdata-documents-spreadsheet.c        |    2 +
 gdata/services/documents/gdata-documents-text.c    |    2 +
 gdata/services/picasaweb/gdata-picasaweb-service.c |   14 ++++++-
 gdata/services/youtube/gdata-youtube-service.c     |   32 ++++++++++++++
 gdata/services/youtube/gdata-youtube-video.c       |    6 +-
 38 files changed, 257 insertions(+), 59 deletions(-)
---
diff --git a/gdata/atom/gdata-author.c b/gdata/atom/gdata-author.c
index 38c0a4f..64d786a 100644
--- a/gdata/atom/gdata-author.c
+++ b/gdata/atom/gdata-author.c
@@ -265,6 +265,9 @@ gdata_author_new (const gchar *name, const gchar *uri, const gchar *email_addres
 gint
 gdata_author_compare (const GDataAuthor *a, const GDataAuthor *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_AUTHOR (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_AUTHOR (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/atom/gdata-category.c b/gdata/atom/gdata-category.c
index d9ce01c..889560f 100644
--- a/gdata/atom/gdata-category.c
+++ b/gdata/atom/gdata-category.c
@@ -254,6 +254,9 @@ gdata_category_new (const gchar *term, const gchar *scheme, const gchar *label)
 gint
 gdata_category_compare (const GDataCategory *a, const GDataCategory *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_CATEGORY (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_CATEGORY (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/atom/gdata-generator.c b/gdata/atom/gdata-generator.c
index acb0ece..3631590 100644
--- a/gdata/atom/gdata-generator.c
+++ b/gdata/atom/gdata-generator.c
@@ -206,6 +206,9 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 gint
 gdata_generator_compare (const GDataGenerator *a, const GDataGenerator *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GENERATOR (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GENERATOR (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/atom/gdata-link.c b/gdata/atom/gdata-link.c
index 82599fc..3d954ca 100644
--- a/gdata/atom/gdata-link.c
+++ b/gdata/atom/gdata-link.c
@@ -373,6 +373,9 @@ gdata_link_new (const gchar *uri, const gchar *relation_type)
 gint
 gdata_link_compare (const GDataLink *a, const GDataLink *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_LINK (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_LINK (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gcontact/gdata-gcontact-calendar.c b/gdata/gcontact/gdata-gcontact-calendar.c
index b8bb77c..a93fbfe 100644
--- a/gdata/gcontact/gdata-gcontact-calendar.c
+++ b/gdata/gcontact/gdata-gcontact-calendar.c
@@ -323,6 +323,9 @@ gdata_gcontact_calendar_new (const gchar *uri, const gchar *relation_type, const
 gint
 gdata_gcontact_calendar_compare (const GDataGContactCalendar *a, const GDataGContactCalendar *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GCONTACT_CALENDAR (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GCONTACT_CALENDAR (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gcontact/gdata-gcontact-external-id.c b/gdata/gcontact/gdata-gcontact-external-id.c
index 6a1ef4f..6698a39 100644
--- a/gdata/gcontact/gdata-gcontact-external-id.c
+++ b/gdata/gcontact/gdata-gcontact-external-id.c
@@ -287,6 +287,9 @@ gdata_gcontact_external_id_new (const gchar *value, const gchar *relation_type,
 gint
 gdata_gcontact_external_id_compare (const GDataGContactExternalID *a, const GDataGContactExternalID *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GCONTACT_EXTERNAL_ID (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GCONTACT_EXTERNAL_ID (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gcontact/gdata-gcontact-language.c b/gdata/gcontact/gdata-gcontact-language.c
index 84796c8..3e7bfe8 100644
--- a/gdata/gcontact/gdata-gcontact-language.c
+++ b/gdata/gcontact/gdata-gcontact-language.c
@@ -246,6 +246,9 @@ gdata_gcontact_language_new (const gchar *code, const gchar *label)
 gint
 gdata_gcontact_language_compare (const GDataGContactLanguage *a, const GDataGContactLanguage *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GCONTACT_LANGUAGE (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GCONTACT_LANGUAGE (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gcontact/gdata-gcontact-website.c b/gdata/gcontact/gdata-gcontact-website.c
index 269ef40..422dc84 100644
--- a/gdata/gcontact/gdata-gcontact-website.c
+++ b/gdata/gcontact/gdata-gcontact-website.c
@@ -307,6 +307,9 @@ gdata_gcontact_website_new (const gchar *uri, const gchar *relation_type, const
 gint
 gdata_gcontact_website_compare (const GDataGContactWebsite *a, const GDataGContactWebsite *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GCONTACT_WEBSITE (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GCONTACT_WEBSITE (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-email-address.c b/gdata/gd/gdata-gd-email-address.c
index d54b889..4a1d9bc 100644
--- a/gdata/gd/gdata-gd-email-address.c
+++ b/gdata/gd/gdata-gd-email-address.c
@@ -336,6 +336,9 @@ gdata_gd_email_address_new (const gchar *address, const gchar *relation_type, co
 gint
 gdata_gd_email_address_compare (const GDataGDEmailAddress *a, const GDataGDEmailAddress *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_EMAIL_ADDRESS (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_EMAIL_ADDRESS (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-im-address.c b/gdata/gd/gdata-gd-im-address.c
index c234a29..960c163 100644
--- a/gdata/gd/gdata-gd-im-address.c
+++ b/gdata/gd/gdata-gd-im-address.c
@@ -315,6 +315,7 @@ GDataGDIMAddress *
 gdata_gd_im_address_new (const gchar *address, const gchar *protocol, const gchar *relation_type, const gchar *label, gboolean is_primary)
 {
 	g_return_val_if_fail (address != NULL && *address != '\0', NULL);
+	g_return_val_if_fail (protocol != NULL && *protocol != '\0', NULL);
 	g_return_val_if_fail (relation_type == NULL || *relation_type != '\0', NULL);
 	return g_object_new (GDATA_TYPE_GD_IM_ADDRESS, "address", address, "protocol", protocol, "relation-type", relation_type,
 			     "label", label, "is-primary", is_primary, NULL);
@@ -339,6 +340,9 @@ gdata_gd_im_address_new (const gchar *address, const gchar *protocol, const gcha
 gint
 gdata_gd_im_address_compare (const GDataGDIMAddress *a, const GDataGDIMAddress *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_IM_ADDRESS (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_IM_ADDRESS (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-name.c b/gdata/gd/gdata-gd-name.c
index e32a5b2..85f608f 100644
--- a/gdata/gd/gdata-gd-name.c
+++ b/gdata/gd/gdata-gd-name.c
@@ -332,6 +332,8 @@ get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
 GDataGDName *
 gdata_gd_name_new (const gchar *given_name, const gchar *family_name)
 {
+	g_return_val_if_fail (given_name == NULL || *given_name != '\0', NULL);
+	g_return_val_if_fail (family_name == NULL || *family_name != '\0', NULL);
 	return g_object_new (GDATA_TYPE_GD_NAME, "given-name", given_name, "family-name", family_name, NULL);
 }
 
@@ -355,6 +357,9 @@ gdata_gd_name_new (const gchar *given_name, const gchar *family_name)
 gint
 gdata_gd_name_compare (const GDataGDName *a, const GDataGDName *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_NAME (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_NAME (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-organization.c b/gdata/gd/gdata-gd-organization.c
index 0c4dad0..6a5126f 100644
--- a/gdata/gd/gdata-gd-organization.c
+++ b/gdata/gd/gdata-gd-organization.c
@@ -483,6 +483,9 @@ gdata_gd_organization_new (const gchar *name, const gchar *title, const gchar *r
 gint
 gdata_gd_organization_compare (const GDataGDOrganization *a, const GDataGDOrganization *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_ORGANIZATION (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_ORGANIZATION (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-phone-number.c b/gdata/gd/gdata-gd-phone-number.c
index 0f45f6a..14eb5e8 100644
--- a/gdata/gd/gdata-gd-phone-number.c
+++ b/gdata/gd/gdata-gd-phone-number.c
@@ -335,6 +335,7 @@ get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
 GDataGDPhoneNumber *
 gdata_gd_phone_number_new (const gchar *number, const gchar *relation_type, const gchar *label, const gchar *uri, gboolean is_primary)
 {
+	g_return_val_if_fail (number != NULL && *number != '\0', NULL);
 	g_return_val_if_fail (relation_type == NULL || *relation_type != '\0', NULL);
 	return g_object_new (GDATA_TYPE_GD_PHONE_NUMBER, "number", number, "uri", uri, "relation-type", relation_type,
 			     "label", label, "is-primary", is_primary, NULL);
@@ -359,6 +360,9 @@ gdata_gd_phone_number_new (const gchar *number, const gchar *relation_type, cons
 gint
 gdata_gd_phone_number_compare (const GDataGDPhoneNumber *a, const GDataGDPhoneNumber *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_PHONE_NUMBER (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_PHONE_NUMBER (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-postal-address.c b/gdata/gd/gdata-gd-postal-address.c
index 81a95e3..56c2ee4 100644
--- a/gdata/gd/gdata-gd-postal-address.c
+++ b/gdata/gd/gdata-gd-postal-address.c
@@ -682,6 +682,9 @@ gdata_gd_postal_address_new (const gchar *relation_type, const gchar *label, gbo
 gint
 gdata_gd_postal_address_compare (const GDataGDPostalAddress *a, const GDataGDPostalAddress *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_POSTAL_ADDRESS (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_POSTAL_ADDRESS (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-reminder.c b/gdata/gd/gdata-gd-reminder.c
index fac7961..0623de8 100644
--- a/gdata/gd/gdata-gd-reminder.c
+++ b/gdata/gd/gdata-gd-reminder.c
@@ -297,6 +297,7 @@ GDataGDReminder *
 gdata_gd_reminder_new (const gchar *method, const GTimeVal *absolute_time, gint relative_time)
 {
 	g_return_val_if_fail (absolute_time == NULL || relative_time == -1, NULL);
+	g_return_val_if_fail (relative_time >= -1, NULL);
 	return g_object_new (GDATA_TYPE_GD_REMINDER, "absolute-time", absolute_time, "relative-time", relative_time, "method", method, NULL);
 }
 
@@ -321,6 +322,9 @@ gdata_gd_reminder_compare (const GDataGDReminder *a, const GDataGDReminder *b)
 {
 	gint method_cmp;
 
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_REMINDER (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_REMINDER (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-when.c b/gdata/gd/gdata-gd-when.c
index 224b99f..0ce516d 100644
--- a/gdata/gd/gdata-gd-when.c
+++ b/gdata/gd/gdata-gd-when.c
@@ -399,6 +399,9 @@ gdata_gd_when_compare (const GDataGDWhen *a, const GDataGDWhen *b)
 {
 	gint64 start_diff, end_diff;
 
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_WHEN (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_WHEN (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-where.c b/gdata/gd/gdata-gd-where.c
index e3a1498..911f60d 100644
--- a/gdata/gd/gdata-gd-where.c
+++ b/gdata/gd/gdata-gd-where.c
@@ -291,6 +291,9 @@ gdata_gd_where_new (const gchar *relation_type, const gchar *value_string, const
 gint
 gdata_gd_where_compare (const GDataGDWhere *a, const GDataGDWhere *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_WHERE (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_WHERE (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gd/gdata-gd-who.c b/gdata/gd/gdata-gd-who.c
index aa1cc8f..263f784 100644
--- a/gdata/gd/gdata-gd-who.c
+++ b/gdata/gd/gdata-gd-who.c
@@ -297,6 +297,9 @@ gdata_gd_who_new (const gchar *relation_type, const gchar *value_string, const g
 gint
 gdata_gd_who_compare (const GDataGDWho *a, const GDataGDWho *b)
 {
+	g_return_val_if_fail (a == NULL || GDATA_IS_GD_WHO (a), 0);
+	g_return_val_if_fail (b == NULL || GDATA_IS_GD_WHO (b), 0);
+
 	if (a == NULL && b != NULL)
 		return -1;
 	else if (a != NULL && b == NULL)
diff --git a/gdata/gdata-access-handler.c b/gdata/gdata-access-handler.c
index aec2e5e..705b691 100644
--- a/gdata/gdata-access-handler.c
+++ b/gdata/gdata-access-handler.c
@@ -159,7 +159,7 @@ gdata_access_handler_insert_rule (GDataAccessHandler *self, GDataService *servic
 	gchar *upload_data;
 	guint status;
 
-	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
+	g_return_val_if_fail (GDATA_IS_ACCESS_HANDLER (self), NULL);
 	g_return_val_if_fail (GDATA_IS_SERVICE (service), NULL);
 	g_return_val_if_fail (GDATA_IS_ACCESS_RULE (rule), NULL);
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
@@ -270,7 +270,7 @@ gdata_access_handler_update_rule (GDataAccessHandler *self, GDataService *servic
 	gchar *upload_data;
 	guint status;
 
-	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
+	g_return_val_if_fail (GDATA_IS_ACCESS_HANDLER (self), NULL);
 	g_return_val_if_fail (GDATA_IS_SERVICE (service), NULL);
 	g_return_val_if_fail (GDATA_IS_ACCESS_RULE (rule), NULL);
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
@@ -336,7 +336,7 @@ gdata_access_handler_delete_rule (GDataAccessHandler *self, GDataService *servic
 	SoupMessage *message;
 	guint status;
 
-	g_return_val_if_fail (GDATA_IS_ENTRY (self), FALSE);
+	g_return_val_if_fail (GDATA_IS_ACCESS_HANDLER (self), FALSE);
 	g_return_val_if_fail (GDATA_IS_SERVICE (service), FALSE);
 	g_return_val_if_fail (GDATA_IS_ACCESS_RULE (rule), FALSE);
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
diff --git a/gdata/gdata-buffer.c b/gdata/gdata-buffer.c
index 0cf4738..9271c41 100644
--- a/gdata/gdata-buffer.c
+++ b/gdata/gdata-buffer.c
@@ -75,6 +75,8 @@ gdata_buffer_free (GDataBuffer *self)
 {
 	GDataBufferChunk *chunk, *next_chunk;
 
+	g_return_if_fail (self != NULL);
+
 	for (chunk = self->head; chunk != NULL; chunk = next_chunk) {
 		next_chunk = chunk->next;
 		g_free (chunk);
@@ -109,6 +111,8 @@ gdata_buffer_push_data (GDataBuffer *self, const guint8 *data, gsize length)
 {
 	GDataBufferChunk *chunk;
 
+	g_return_val_if_fail (self != NULL, 0);
+
 	g_static_mutex_lock (&(self->mutex));
 
 	if (G_UNLIKELY (self->reached_eof == TRUE)) {
@@ -194,13 +198,18 @@ gdata_buffer_pop_data (GDataBuffer *self, guint8 *data, gsize length_requested,
 	GDataBufferChunk *chunk;
 	gsize return_length = 0, length_remaining;
 
+	g_return_val_if_fail (self != NULL, 0);
+	g_return_val_if_fail (data != NULL, 0);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), 0);
+
 	/* In the case:
 	 *  - length_requested < amount available: return length_requested
 	 *  - length_requested > amount available: block until more is available, return length_requested
 	 *  - length_requested > amount available and we've reached EOF: don't block, return all remaining data
 	 *  - length_requested is a whole number of chunks: remove those chunks, return length_requested
 	 *  - length_requested is less than one chunk: remove no chunks, return length_requested, set head_read_offset
-	 *  - length_requested is a fraction of multiple chunks: remove whole chunks, return length_requested, set head_read_offset for remaining fraction
+	 *  - length_requested is a fraction of multiple chunks: remove whole chunks, return length_requested, set head_read_offset
+	 *    for remaining fraction
 	 */
 
 	g_static_mutex_lock (&(self->mutex));
@@ -302,7 +311,7 @@ gdata_buffer_pop_data (GDataBuffer *self, guint8 *data, gsize length_requested,
  * @maximum_length: the maximum number of bytes to return
  * @reached_eof: return location for a value which is %TRUE when we've reached EOF, %FALSE otherwise, or %NULL
  *
- * Pops as much data as possible off the #GDataBuffer, up to a limit of @maxium_length bytes. If fewer bytes exist
+ * Pops as much data as possible off the #GDataBuffer, up to a limit of @maximum_length bytes. If fewer bytes exist
  * in the buffer, fewer bytes will be returned. If more bytes exist in the buffer, @maximum_length bytes will be returned.
  *
  * If <code class="literal">0</code> bytes exist in the buffer, this function will block until data is available. Otherwise, it will never block.
@@ -314,6 +323,10 @@ gdata_buffer_pop_data (GDataBuffer *self, guint8 *data, gsize length_requested,
 gsize
 gdata_buffer_pop_data_limited (GDataBuffer *self, guint8 *data, gsize maximum_length, gboolean *reached_eof)
 {
+	g_return_val_if_fail (self != NULL, 0);
+	g_return_val_if_fail (data != NULL, 0);
+	g_return_val_if_fail (maximum_length > 0, 0);
+
 	/* If there's no data in the buffer, block until some is available */
 	g_static_mutex_lock (&(self->mutex));
 	if (self->total_length == 0 && self->reached_eof == FALSE)
diff --git a/gdata/gdata-entry.c b/gdata/gdata-entry.c
index ddc81ee..c883ae3 100644
--- a/gdata/gdata-entry.c
+++ b/gdata/gdata-entry.c
@@ -689,7 +689,7 @@ gdata_entry_get_content (GDataEntry *self)
 /**
  * gdata_entry_set_content:
  * @self: a #GDataEntry
- * @content: the new content for the entry
+ * @content: the new content for the entry, or %NULL
  *
  * Sets the entry's content to @content.
  **/
@@ -802,7 +802,7 @@ gdata_entry_add_author (GDataEntry *self, GDataAuthor *author)
 {
 	/* TODO: More author API */
 	g_return_if_fail (GDATA_IS_ENTRY (self));
-	g_return_if_fail (author != NULL);
+	g_return_if_fail (GDATA_IS_AUTHOR (author));
 
 	if (g_list_find_custom (self->priv->authors, author, (GCompareFunc) gdata_author_compare) == NULL)
 		self->priv->authors = g_list_prepend (self->priv->authors, g_object_ref (author));
diff --git a/gdata/gdata-feed.c b/gdata/gdata-feed.c
index 9a6eff3..dc56e1b 100644
--- a/gdata/gdata-feed.c
+++ b/gdata/gdata-feed.c
@@ -694,7 +694,7 @@ gdata_feed_get_authors (GDataFeed *self)
 static void
 _gdata_feed_add_author (GDataFeed *self, GDataAuthor *author)
 {
-		self->priv->authors = g_list_prepend (self->priv->authors, g_object_ref (author));
+	self->priv->authors = g_list_prepend (self->priv->authors, g_object_ref (author));
 }
 
 /**
diff --git a/gdata/gdata-parsable.c b/gdata/gdata-parsable.c
index ef7e45c..8d4ccd8 100644
--- a/gdata/gdata-parsable.c
+++ b/gdata/gdata-parsable.c
@@ -144,6 +144,11 @@ real_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer us
 GDataParsable *
 gdata_parsable_new_from_xml (GType parsable_type, const gchar *xml, gint length, GError **error)
 {
+	g_return_val_if_fail (g_type_is_a (parsable_type, GDATA_TYPE_PARSABLE), NULL);
+	g_return_val_if_fail (xml != NULL && *xml != '\0', NULL);
+	g_return_val_if_fail (length >= -1, NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	return _gdata_parsable_new_from_xml (parsable_type, xml, length, NULL, error);
 }
 
@@ -158,6 +163,7 @@ _gdata_parsable_new_from_xml (GType parsable_type, const gchar *xml, gint length
 	g_return_val_if_fail (g_type_is_a (parsable_type, GDATA_TYPE_PARSABLE), NULL);
 	g_return_val_if_fail (xml != NULL && *xml != '\0', NULL);
 	g_return_val_if_fail (length >= -1, NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	/* Set up libxml. We do this here to avoid introducing a libgdata setup function, which would be unnecessary hassle. This is the only place
 	 * that libxml can be initialised in the library. */
@@ -209,6 +215,7 @@ _gdata_parsable_new_from_xml_node (GType parsable_type, xmlDoc *doc, xmlNode *no
 	g_return_val_if_fail (g_type_is_a (parsable_type, GDATA_TYPE_PARSABLE), NULL);
 	g_return_val_if_fail (doc != NULL, NULL);
 	g_return_val_if_fail (node != NULL, NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	parsable = g_object_new (parsable_type, NULL);
 
@@ -292,6 +299,7 @@ gdata_parsable_get_xml (GDataParsable *self)
 /*
  * _gdata_parsable_get_xml:
  * @self: a #GDataParsable
+ * @xml_string: a #GString to build the XML in
  * @declare_namespaces: %TRUE if all the namespaces used in the outputted XML should be declared in the opening tag of the root element, %FALSE otherwise
  *
  * Builds an XML representation of the #GDataParsable in its current state, such that it could be inserted on the server. If @declare_namespaces is
@@ -309,6 +317,9 @@ _gdata_parsable_get_xml (GDataParsable *self, GString *xml_string, gboolean decl
 	guint length;
 	GHashTable *namespaces = NULL; /* shut up, gcc */
 
+	g_return_if_fail (GDATA_IS_PARSABLE (self));
+	g_return_if_fail (xml_string != NULL);
+
 	klass = GDATA_PARSABLE_GET_CLASS (self);
 	g_assert (klass->element_name != NULL);
 
diff --git a/gdata/gdata-query.c b/gdata/gdata-query.c
index 580d64c..9e50289 100644
--- a/gdata/gdata-query.c
+++ b/gdata/gdata-query.c
@@ -548,6 +548,9 @@ gdata_query_get_query_uri (GDataQuery *self, const gchar *feed_uri)
 	GString *query_uri;
 	gboolean params_started;
 
+	g_return_val_if_fail (GDATA_IS_QUERY (self), NULL);
+	g_return_val_if_fail (feed_uri != NULL, NULL);
+
 	/* Check to see if we're paginating first */
 	if (self->priv->use_next_uri == TRUE)
 		return g_strdup (self->priv->next_uri);
@@ -1079,6 +1082,8 @@ gdata_query_next_page (GDataQuery *self)
 {
 	GDataQueryPrivate *priv = self->priv;
 
+	g_return_if_fail (GDATA_IS_QUERY (self));
+
 	if (priv->next_uri != NULL) {
 		priv->use_next_uri = TRUE;
 		priv->use_previous_uri = FALSE;
@@ -1108,6 +1113,8 @@ gdata_query_previous_page (GDataQuery *self)
 {
 	GDataQueryPrivate *priv = self->priv;
 
+	g_return_val_if_fail (GDATA_IS_QUERY (self), FALSE);
+
 	if (priv->next_uri != NULL) {
 		priv->use_previous_uri = TRUE;
 		priv->use_next_uri = FALSE;
diff --git a/gdata/gdata-service.c b/gdata/gdata-service.c
index edb67f6..71c68a3 100644
--- a/gdata/gdata-service.c
+++ b/gdata/gdata-service.c
@@ -606,10 +606,6 @@ authenticate (GDataService *self, const gchar *username, const gchar *password,
 	guint status;
 	gboolean retval;
 
-	g_return_val_if_fail (GDATA_IS_SERVICE (self), FALSE);
-	g_return_val_if_fail (username != NULL, FALSE);
-	g_return_val_if_fail (password != NULL, FALSE);
-
 	/* Prepare the request */
 	klass = GDATA_SERVICE_GET_CLASS (self);
 	request_body = soup_form_encode ("accountType", "HOSTED_OR_GOOGLE",
diff --git a/gdata/gdata-upload-stream.c b/gdata/gdata-upload-stream.c
index 23dee7c..b9b3086 100644
--- a/gdata/gdata-upload-stream.c
+++ b/gdata/gdata-upload-stream.c
@@ -580,6 +580,7 @@ gdata_upload_stream_new (GDataService *service, const gchar *method, const gchar
 	SoupMessage *message;
 
 	g_return_val_if_fail (GDATA_IS_SERVICE (service), NULL);
+	g_return_val_if_fail (method != NULL, NULL);
 	g_return_val_if_fail (upload_uri != NULL, NULL);
 	g_return_val_if_fail (entry == NULL || GDATA_IS_ENTRY (entry), NULL);
 	g_return_val_if_fail (slug != NULL, NULL);
diff --git a/gdata/media/gdata-media-group.c b/gdata/media/gdata-media-group.c
index d523f78..f75a538 100644
--- a/gdata/media/gdata-media-group.c
+++ b/gdata/media/gdata-media-group.c
@@ -498,6 +498,8 @@ gdata_media_group_get_contents (GDataMediaGroup *self)
 void
 _gdata_media_group_add_content (GDataMediaGroup *self, GDataMediaContent *content)
 {
+	g_return_if_fail (GDATA_IS_MEDIA_GROUP (self));
+	g_return_if_fail (GDATA_IS_MEDIA_CONTENT (content));
 	self->priv->contents = g_list_prepend (self->priv->contents, g_object_ref (content));
 }
 
@@ -519,6 +521,9 @@ gdata_media_group_get_credit (GDataMediaGroup *self)
 void
 _gdata_media_group_set_credit (GDataMediaGroup *self, GDataMediaCredit *credit)
 {
+	g_return_if_fail (GDATA_IS_MEDIA_GROUP (self));
+	g_return_if_fail (credit == NULL ||GDATA_IS_MEDIA_CREDIT (credit));
+
 	if (self->priv->credit != NULL)
 		g_object_unref (self->priv->credit);
 	self->priv->credit = g_object_ref (credit);
@@ -579,5 +584,7 @@ gdata_media_group_get_thumbnails (GDataMediaGroup *self)
 void
 _gdata_media_group_add_thumbnail (GDataMediaGroup *self, GDataMediaThumbnail *thumbnail)
 {
+	g_return_if_fail (GDATA_IS_MEDIA_GROUP (self));
+	g_return_if_fail (GDATA_IS_MEDIA_THUMBNAIL (thumbnail));
 	self->priv->thumbnails = g_list_prepend (self->priv->thumbnails, g_object_ref (thumbnail));
 }
diff --git a/gdata/services/calendar/gdata-calendar-calendar.c b/gdata/services/calendar/gdata-calendar-calendar.c
index 5f27289..a469fe6 100644
--- a/gdata/services/calendar/gdata-calendar-calendar.c
+++ b/gdata/services/calendar/gdata-calendar-calendar.c
@@ -270,26 +270,6 @@ gdata_calendar_calendar_set_property (GObject *object, guint property_id, const
 	}
 }
 
-/**
- * gdata_calendar_calendar_new:
- * @id: the calendar's ID, or %NULL
- *
- * Creates a new #GDataCalendarCalendar with the given ID and default properties.
- *
- * Return value: a new #GDataCalendarCalendar; unref with g_object_unref()
- **/
-GDataCalendarCalendar *
-gdata_calendar_calendar_new (const gchar *id)
-{
-	GDataCalendarCalendar *calendar = GDATA_CALENDAR_CALENDAR (g_object_new (GDATA_TYPE_CALENDAR_CALENDAR, "id", id, NULL));
-
-	/* Set the edited property to the current time (creation time). We don't do this in *_init() since that would cause
-	 * setting it from parse_xml() to fail (duplicate element). */
-	g_get_current_time (&(calendar->priv->edited));
-
-	return calendar;
-}
-
 static gboolean
 parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
 {
@@ -400,6 +380,26 @@ get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
 }
 
 /**
+ * gdata_calendar_calendar_new:
+ * @id: the calendar's ID, or %NULL
+ *
+ * Creates a new #GDataCalendarCalendar with the given ID and default properties.
+ *
+ * Return value: a new #GDataCalendarCalendar; unref with g_object_unref()
+ **/
+GDataCalendarCalendar *
+gdata_calendar_calendar_new (const gchar *id)
+{
+	GDataCalendarCalendar *calendar = GDATA_CALENDAR_CALENDAR (g_object_new (GDATA_TYPE_CALENDAR_CALENDAR, "id", id, NULL));
+
+	/* Set the edited property to the current time (creation time). We don't do this in *_init() since that would cause
+	 * setting it from parse_xml() to fail (duplicate element). */
+	g_get_current_time (&(calendar->priv->edited));
+
+	return calendar;
+}
+
+/**
  * gdata_calendar_calendar_get_timezone:
  * @self: a #GDataCalendarCalendar
  *
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index 8ae0051..38842f1 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -430,26 +430,6 @@ gdata_calendar_event_set_property (GObject *object, guint property_id, const GVa
 	}
 }
 
-/**
- * gdata_calendar_event_new:
- * @id: the event's ID, or %NULL
- *
- * Creates a new #GDataCalendarEvent with the given ID and default properties.
- *
- * Return value: a new #GDataCalendarEvent; unref with g_object_unref()
- **/
-GDataCalendarEvent *
-gdata_calendar_event_new (const gchar *id)
-{
-	GDataCalendarEvent *event = GDATA_CALENDAR_EVENT (g_object_new (GDATA_TYPE_CALENDAR_EVENT, "id", id, NULL));
-
-	/* Set the edited property to the current time (creation time). We don't do this in *_init() since that would cause
-	 * setting it from parse_xml() to fail (duplicate element). */
-	g_get_current_time (&(event->priv->edited));
-
-	return event;
-}
-
 static gboolean
 parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
 {
@@ -657,6 +637,26 @@ get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
 }
 
 /**
+ * gdata_calendar_event_new:
+ * @id: the event's ID, or %NULL
+ *
+ * Creates a new #GDataCalendarEvent with the given ID and default properties.
+ *
+ * Return value: a new #GDataCalendarEvent; unref with g_object_unref()
+ **/
+GDataCalendarEvent *
+gdata_calendar_event_new (const gchar *id)
+{
+	GDataCalendarEvent *event = GDATA_CALENDAR_EVENT (g_object_new (GDATA_TYPE_CALENDAR_EVENT, "id", id, NULL));
+
+	/* Set the edited property to the current time (creation time). We don't do this in *_init() since that would cause
+	 * setting it from parse_xml() to fail (duplicate element). */
+	g_get_current_time (&(event->priv->edited));
+
+	return event;
+}
+
+/**
  * gdata_calendar_event_get_edited:
  * @self: a #GDataCalendarEvent
  * @edited: a #GTimeVal
@@ -831,7 +831,7 @@ gdata_calendar_event_get_sequence (GDataCalendarEvent *self)
 /**
  * gdata_calendar_event_set_sequence:
  * @self: a #GDataCalendarEvent
- * @sequence: a new sequence number, or %NULL
+ * @sequence: a new sequence number, or <code class="literal">0</code>
  *
  * Sets the #GDataCalendarEvent:sequence property to the new sequence number, @sequence.
  **/
@@ -976,7 +976,7 @@ void
 gdata_calendar_event_add_person (GDataCalendarEvent *self, GDataGDWho *who)
 {
 	g_return_if_fail (GDATA_IS_CALENDAR_EVENT (self));
-	g_return_if_fail (who != NULL);
+	g_return_if_fail (GDATA_IS_GD_WHO (who));
 
 	if (g_list_find_custom (self->priv->people, who, (GCompareFunc) gdata_gd_who_compare) == NULL)
 		self->priv->people = g_list_append (self->priv->people, g_object_ref (who));
@@ -1012,7 +1012,7 @@ void
 gdata_calendar_event_add_place (GDataCalendarEvent *self, GDataGDWhere *where)
 {
 	g_return_if_fail (GDATA_IS_CALENDAR_EVENT (self));
-	g_return_if_fail (where != NULL);
+	g_return_if_fail (GDATA_IS_GD_WHERE (where));
 
 	if (g_list_find_custom (self->priv->places, where, (GCompareFunc) gdata_gd_where_compare) == NULL)
 		self->priv->places = g_list_append (self->priv->places, g_object_ref (where));
diff --git a/gdata/services/calendar/gdata-calendar-service.c b/gdata/services/calendar/gdata-calendar-service.c
index 240f087..ab6d2f5 100644
--- a/gdata/services/calendar/gdata-calendar-service.c
+++ b/gdata/services/calendar/gdata-calendar-service.c
@@ -102,6 +102,11 @@ gdata_calendar_service_query_all_calendars (GDataCalendarService *self, GDataQue
 	GDataFeed *feed;
 	gchar *request_uri;
 
+	g_return_val_if_fail (GDATA_IS_CALENDAR_SERVICE (self), NULL);
+	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	/* Ensure we're authenticated first */
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
@@ -141,6 +146,11 @@ gdata_calendar_service_query_all_calendars_async (GDataCalendarService *self, GD
 {
 	gchar *request_uri;
 
+	g_return_if_fail (GDATA_IS_CALENDAR_SERVICE (self));
+	g_return_if_fail (query == NULL || GDATA_IS_QUERY (query));
+	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+	g_return_if_fail (callback != NULL);
+
 	/* Ensure we're authenticated first */
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_simple_async_report_error_in_idle (G_OBJECT (self), callback, user_data,
@@ -179,6 +189,11 @@ gdata_calendar_service_query_own_calendars (GDataCalendarService *self, GDataQue
 	GDataFeed *feed;
 	gchar *request_uri;
 
+	g_return_val_if_fail (GDATA_IS_CALENDAR_SERVICE (self), NULL);
+	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	/* Ensure we're authenticated first */
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
@@ -218,6 +233,11 @@ gdata_calendar_service_query_own_calendars_async (GDataCalendarService *self, GD
 {
 	gchar *request_uri;
 
+	g_return_if_fail (GDATA_IS_CALENDAR_SERVICE (self));
+	g_return_if_fail (query == NULL || GDATA_IS_QUERY (query));
+	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+	g_return_if_fail (callback != NULL);
+
 	/* Ensure we're authenticated first */
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_simple_async_report_error_in_idle (G_OBJECT (self), callback, user_data,
@@ -255,6 +275,12 @@ gdata_calendar_service_query_events (GDataCalendarService *self, GDataCalendarCa
 	/* TODO: Async variant */
 	const gchar *uri;
 
+	g_return_val_if_fail (GDATA_IS_CALENDAR_SERVICE (self), NULL);
+	g_return_val_if_fail (GDATA_IS_CALENDAR_CALENDAR (calendar), NULL);
+	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	/* Ensure we're authenticated first */
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
@@ -301,6 +327,8 @@ gdata_calendar_service_insert_event (GDataCalendarService *self, GDataCalendarEv
 
 	g_return_val_if_fail (GDATA_IS_CALENDAR_SERVICE (self), NULL);
 	g_return_val_if_fail (GDATA_IS_CALENDAR_EVENT (event), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	uri = g_strdup_printf ("%s://www.google.com/calendar/feeds/%s/private/full",
 	                       _gdata_service_get_scheme (), gdata_service_get_username (GDATA_SERVICE (self)));
diff --git a/gdata/services/contacts/gdata-contacts-service.c b/gdata/services/contacts/gdata-contacts-service.c
index 1ff414e..5a20c46 100644
--- a/gdata/services/contacts/gdata-contacts-service.c
+++ b/gdata/services/contacts/gdata-contacts-service.c
@@ -103,6 +103,11 @@ gdata_contacts_service_query_contacts (GDataContactsService *self, GDataQuery *q
 	GDataFeed *feed;
 	gchar *request_uri;
 
+	g_return_val_if_fail (GDATA_IS_CONTACTS_SERVICE (self), NULL);
+	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	/* Ensure we're authenticated first */
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
@@ -143,6 +148,11 @@ gdata_contacts_service_query_contacts_async (GDataContactsService *self, GDataQu
 {
 	gchar *request_uri;
 
+	g_return_if_fail (GDATA_IS_CONTACTS_SERVICE (self));
+	g_return_if_fail (query == NULL || GDATA_IS_QUERY (query));
+	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+	g_return_if_fail (callback != NULL);
+
 	/* Ensure we're authenticated first */
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_simple_async_report_error_in_idle (G_OBJECT (self), callback, user_data,
@@ -181,6 +191,8 @@ gdata_contacts_service_insert_contact (GDataContactsService *self, GDataContacts
 
 	g_return_val_if_fail (GDATA_IS_CONTACTS_SERVICE (self), NULL);
 	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (contact), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	uri = g_strdup_printf ("%s://www.google.com/m8/feeds/contacts/%s/full",
 	                       _gdata_service_get_scheme (),
@@ -215,6 +227,8 @@ gdata_contacts_service_update_contact (GDataContactsService *self, GDataContacts
 
 	g_return_val_if_fail (GDATA_IS_CONTACTS_SERVICE (self), NULL);
 	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (contact), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	/* Can't trust the edit URI the contact gives us, as it has the wrong projection; it uses the base projection, which
 	 * doesn't allow for extended attributes to be set (for some weird reason). */
diff --git a/gdata/services/documents/gdata-documents-presentation.c b/gdata/services/documents/gdata-documents-presentation.c
index c1eab8b..bf5a9b8 100644
--- a/gdata/services/documents/gdata-documents-presentation.c
+++ b/gdata/services/documents/gdata-documents-presentation.c
@@ -142,6 +142,7 @@ gdata_documents_presentation_download_document (GDataDocumentsPresentation *self
 	g_return_val_if_fail (G_IS_FILE (destination_file), NULL);
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
 	g_return_val_if_fail (export_format < G_N_ELEMENTS (export_formats), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	/* Call the common download method on the parent class */
 	link_href = gdata_documents_presentation_get_download_uri (self, export_format);
@@ -170,6 +171,7 @@ gdata_documents_presentation_get_download_uri (GDataDocumentsPresentation *self,
 {
 	const gchar *document_id;
 
+	g_return_val_if_fail (GDATA_IS_DOCUMENTS_PRESENTATION (self), NULL);
 	g_return_val_if_fail (export_format < G_N_ELEMENTS (export_formats), NULL);
 
 	document_id = gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (self));
diff --git a/gdata/services/documents/gdata-documents-service.c b/gdata/services/documents/gdata-documents-service.c
index 87770c7..aa6f1e2 100644
--- a/gdata/services/documents/gdata-documents-service.c
+++ b/gdata/services/documents/gdata-documents-service.c
@@ -187,6 +187,11 @@ gdata_documents_service_query_documents (GDataDocumentsService *self, GDataDocum
 	GDataFeed *feed;
 	gchar *request_uri;
 
+	g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self), NULL);
+	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	/* Ensure we're authenticated first */
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
@@ -232,6 +237,11 @@ gdata_documents_service_query_documents_async (GDataDocumentsService *self, GDat
 {
 	gchar *request_uri;
 
+	g_return_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self));
+	g_return_if_fail (query == NULL || GDATA_IS_QUERY (query));
+	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+	g_return_if_fail (callback != NULL);
+
 	/* Ensure we're authenticated first */
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_simple_async_report_error_in_idle (G_OBJECT (self), callback, user_data,
@@ -413,6 +423,7 @@ gdata_documents_service_upload_document (GDataDocumentsService *self, GDataDocum
 	g_return_val_if_fail (document != NULL || document_file != NULL, NULL);
 	g_return_val_if_fail (folder == NULL || GDATA_IS_DOCUMENTS_FOLDER (folder), NULL);
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
@@ -469,6 +480,7 @@ gdata_documents_service_update_document (GDataDocumentsService *self, GDataDocum
 	g_return_val_if_fail (GDATA_IS_DOCUMENTS_ENTRY (document), NULL);
 	g_return_val_if_fail (document_file == NULL || G_IS_FILE (document_file), NULL);
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	if (gdata_service_is_authenticated (GDATA_SERVICE (self)) == FALSE) {
 		g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
diff --git a/gdata/services/documents/gdata-documents-spreadsheet.c b/gdata/services/documents/gdata-documents-spreadsheet.c
index b05b353..f364ab9 100644
--- a/gdata/services/documents/gdata-documents-spreadsheet.c
+++ b/gdata/services/documents/gdata-documents-spreadsheet.c
@@ -152,6 +152,7 @@ gdata_documents_spreadsheet_download_document (GDataDocumentsSpreadsheet *self,
 	g_return_val_if_fail ((export_format != GDATA_DOCUMENTS_SPREADSHEET_CSV && export_format != GDATA_DOCUMENTS_SPREADSHEET_TSV) || gid != -1, NULL);
 	g_return_val_if_fail (G_IS_FILE (destination_file), NULL);
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	extension = export_formats[export_format].extension;
 
@@ -191,6 +192,7 @@ gdata_documents_spreadsheet_get_download_uri (GDataDocumentsSpreadsheet *self, G
 {
 	const gchar *document_id, *fmcmd;
 
+	g_return_val_if_fail (GDATA_IS_DOCUMENTS_SPREADSHEET (self), NULL);
 	g_return_val_if_fail (export_format < G_N_ELEMENTS (export_formats), NULL);
 	g_return_val_if_fail (gid >= -1, NULL);
 	g_return_val_if_fail ((export_format != GDATA_DOCUMENTS_SPREADSHEET_CSV && export_format != GDATA_DOCUMENTS_SPREADSHEET_TSV) || gid != -1, NULL);
diff --git a/gdata/services/documents/gdata-documents-text.c b/gdata/services/documents/gdata-documents-text.c
index 3738262..95c0a87 100644
--- a/gdata/services/documents/gdata-documents-text.c
+++ b/gdata/services/documents/gdata-documents-text.c
@@ -144,6 +144,7 @@ gdata_documents_text_download_document (GDataDocumentsText *self, GDataDocuments
 	g_return_val_if_fail (export_format < G_N_ELEMENTS (export_formats), NULL);
 	g_return_val_if_fail (G_IS_FILE (destination_file), NULL);
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	/* Download the file */
 	link_href = gdata_documents_text_get_download_uri (self, export_format);
@@ -173,6 +174,7 @@ gdata_documents_text_get_download_uri (GDataDocumentsText *self, GDataDocumentsT
 {
 	const gchar *document_id;
 
+	g_return_val_if_fail (GDATA_IS_DOCUMENTS_TEXT (self), NULL);
 	g_return_val_if_fail (export_format < G_N_ELEMENTS (export_formats), NULL);
 
 	document_id = gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (self));
diff --git a/gdata/services/picasaweb/gdata-picasaweb-service.c b/gdata/services/picasaweb/gdata-picasaweb-service.c
index c31f2bb..457577b 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-service.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-service.c
@@ -129,6 +129,8 @@ gdata_picasaweb_service_get_user (GDataPicasaWebService *self, const gchar *user
 	SoupMessage *message;
 
 	g_return_val_if_fail (GDATA_IS_PICASAWEB_SERVICE (self), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	uri = create_uri (self, username, "entry");
 	if (uri == NULL) {
@@ -181,6 +183,8 @@ gdata_picasaweb_service_query_all_albums (GDataPicasaWebService *self, GDataQuer
 
 	g_return_val_if_fail (GDATA_IS_PICASAWEB_SERVICE (self), NULL);
 	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	if (query != NULL && gdata_query_get_q (query) != NULL) {
 		/* Bug #593336 â?? Query parameter "q=..." isn't valid for album kinds */
@@ -233,6 +237,7 @@ gdata_picasaweb_service_query_all_albums_async (GDataPicasaWebService *self, GDa
 
 	g_return_if_fail (GDATA_IS_PICASAWEB_SERVICE (self));
 	g_return_if_fail (query == NULL || GDATA_IS_QUERY (query));
+	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
 	g_return_if_fail (callback != NULL);
 
 	if (query != NULL && gdata_query_get_q (query) != NULL) {
@@ -283,6 +288,12 @@ gdata_picasaweb_service_query_files (GDataPicasaWebService *self, GDataPicasaWeb
 	/* TODO: Async variant */
 	const gchar *uri;
 
+	g_return_val_if_fail (GDATA_IS_PICASAWEB_SERVICE (self), NULL);
+	g_return_val_if_fail (album == NULL || GDATA_IS_PICASAWEB_ALBUM (album), NULL);
+	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	if (album != NULL) {
 		GDataLink *link = gdata_entry_look_up_link (GDATA_ENTRY (album), "http://schemas.google.com/g/2005#feed";);
 		if (link == NULL) {
@@ -388,8 +399,8 @@ gdata_picasaweb_service_upload_file (GDataPicasaWebService *self, GDataPicasaWeb
 	g_return_val_if_fail (album == NULL || GDATA_IS_PICASAWEB_ALBUM (album), NULL);
 	g_return_val_if_fail (GDATA_IS_PICASAWEB_FILE (file_entry), NULL);
 	g_return_val_if_fail (G_IS_FILE (file_data), NULL);
-	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	if (gdata_entry_is_inserted (GDATA_ENTRY (file_entry)) == TRUE) {
 		g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_ENTRY_ALREADY_INSERTED,
@@ -459,6 +470,7 @@ GDataPicasaWebFile *
 gdata_picasaweb_service_upload_file_finish (GDataPicasaWebService *self, GAsyncResult *result, GError **error)
 {
 	g_return_val_if_fail (GDATA_IS_PICASAWEB_SERVICE (self), NULL);
+	g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
 	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
 	/* propagate any potential errors we might have encountered in g_output_stream_splice() or gdata_picasaweb_service_upload_file_async() */
diff --git a/gdata/services/youtube/gdata-youtube-service.c b/gdata/services/youtube/gdata-youtube-service.c
index 603354a..74975d8 100644
--- a/gdata/services/youtube/gdata-youtube-service.c
+++ b/gdata/services/youtube/gdata-youtube-service.c
@@ -426,6 +426,11 @@ gdata_youtube_service_query_standard_feed (GDataYouTubeService *self, GDataYouTu
 					   GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
 					   GError **error)
 {
+	g_return_val_if_fail (GDATA_IS_YOUTUBE_SERVICE (self), NULL);
+	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	/* TODO: Support the "time" parameter, as well as category- and region-specific feeds */
 	return gdata_service_query (GDATA_SERVICE (self), standard_feed_type_to_feed_uri (feed_type), query,
 				    GDATA_TYPE_YOUTUBE_VIDEO, cancellable, progress_callback, progress_user_data, error);
@@ -455,6 +460,11 @@ gdata_youtube_service_query_standard_feed_async (GDataYouTubeService *self, GDat
 						 GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
 						 GAsyncReadyCallback callback, gpointer user_data)
 {
+	g_return_if_fail (GDATA_IS_YOUTUBE_SERVICE (self));
+	g_return_if_fail (query == NULL || GDATA_IS_QUERY (query));
+	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+	g_return_if_fail (callback != NULL);
+
 	gdata_service_query_async (GDATA_SERVICE (self), standard_feed_type_to_feed_uri (feed_type), query,
 				   GDATA_TYPE_YOUTUBE_VIDEO, cancellable, progress_callback, progress_user_data, callback, user_data);
 }
@@ -480,6 +490,11 @@ gdata_youtube_service_query_videos (GDataYouTubeService *self, GDataQuery *query
 				    GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
 				    GError **error)
 {
+	g_return_val_if_fail (GDATA_IS_YOUTUBE_SERVICE (self), NULL);
+	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	return gdata_service_query (GDATA_SERVICE (self), "http://gdata.youtube.com/feeds/api/videos";, query,
 				    GDATA_TYPE_YOUTUBE_VIDEO, cancellable, progress_callback, progress_user_data, error);
 }
@@ -507,6 +522,11 @@ gdata_youtube_service_query_videos_async (GDataYouTubeService *self, GDataQuery
 					  GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
 					  GAsyncReadyCallback callback, gpointer user_data)
 {
+	g_return_if_fail (GDATA_IS_YOUTUBE_SERVICE (self));
+	g_return_if_fail (query == NULL || GDATA_IS_QUERY (query));
+	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+	g_return_if_fail (callback != NULL);
+
 	gdata_service_query_async (GDATA_SERVICE (self), "http://gdata.youtube.com/feeds/api/videos";, query,
 				   GDATA_TYPE_YOUTUBE_VIDEO, cancellable, progress_callback, progress_user_data, callback, user_data);
 }
@@ -535,6 +555,12 @@ gdata_youtube_service_query_related (GDataYouTubeService *self, GDataYouTubeVide
 {
 	GDataLink *related_link;
 
+	g_return_val_if_fail (GDATA_IS_YOUTUBE_SERVICE (self), NULL);
+	g_return_val_if_fail (GDATA_IS_YOUTUBE_VIDEO (video), NULL);
+	g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL);
+	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
 	/* See if the video already has a rel="http://gdata.youtube.com/schemas/2007#video.related"; link */
 	related_link = gdata_entry_look_up_link (GDATA_ENTRY (video), "http://gdata.youtube.com/schemas/2007#video.related";);
 	if (related_link == NULL) {
@@ -575,6 +601,12 @@ gdata_youtube_service_query_related_async (GDataYouTubeService *self, GDataYouTu
 {
 	GDataLink *related_link;
 
+	g_return_if_fail (GDATA_IS_YOUTUBE_SERVICE (self));
+	g_return_if_fail (GDATA_IS_YOUTUBE_VIDEO (video));
+	g_return_if_fail (query == NULL || GDATA_IS_QUERY (query));
+	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+	g_return_if_fail (callback != NULL);
+
 	/* See if the video already has a rel="http://gdata.youtube.com/schemas/2007#video.related"; link */
 	related_link = gdata_entry_look_up_link (GDATA_ENTRY (video), "http://gdata.youtube.com/schemas/2007#video.related";);
 	if (related_link == NULL) {
diff --git a/gdata/services/youtube/gdata-youtube-video.c b/gdata/services/youtube/gdata-youtube-video.c
index 20cd7b0..36b1e99 100644
--- a/gdata/services/youtube/gdata-youtube-video.c
+++ b/gdata/services/youtube/gdata-youtube-video.c
@@ -998,8 +998,6 @@ gdata_youtube_video_set_access_control (GDataYouTubeVideo *self, const gchar *ac
 {
 	g_return_if_fail (GDATA_IS_YOUTUBE_VIDEO (self));
 	g_return_if_fail (action != NULL);
-	g_return_if_fail (strcmp (action, GDATA_YOUTUBE_ACTION_RATE) == 0 || strcmp (action, GDATA_YOUTUBE_ACTION_COMMENT) == 0 ||
-	                  permission != GDATA_YOUTUBE_PERMISSION_MODERATED);
 
 	g_hash_table_replace (self->priv->access_controls, g_strdup (action), GINT_TO_POINTER (permission));
 }
@@ -1056,8 +1054,8 @@ gdata_youtube_video_get_keywords (GDataYouTubeVideo *self)
 void
 gdata_youtube_video_set_keywords (GDataYouTubeVideo *self, const gchar * const *keywords)
 {
-	g_return_if_fail (keywords != NULL);
 	g_return_if_fail (GDATA_IS_YOUTUBE_VIDEO (self));
+	g_return_if_fail (keywords != NULL);
 
 	gdata_media_group_set_keywords (self->priv->media_group, keywords);
 	g_object_notify (G_OBJECT (self), "keywords");
@@ -1273,6 +1271,7 @@ void
 gdata_youtube_video_get_uploaded (GDataYouTubeVideo *self, GTimeVal *uploaded)
 {
 	g_return_if_fail (GDATA_IS_YOUTUBE_VIDEO (self));
+	g_return_if_fail (uploaded != NULL);
 	gdata_youtube_group_get_uploaded (GDATA_YOUTUBE_GROUP (self->priv->media_group), uploaded);
 }
 
@@ -1353,6 +1352,7 @@ void
 gdata_youtube_video_get_recorded (GDataYouTubeVideo *self, GTimeVal *recorded)
 {
 	g_return_if_fail (GDATA_IS_YOUTUBE_VIDEO (self));
+	g_return_if_fail (recorded != NULL);
 	*recorded = self->priv->recorded;
 }
 



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