[libgdata] [documents] Warning fixes and extra error checking



commit f79e6196edb542911c2fde15756676f7f1753f70
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Aug 2 19:32:48 2009 +0100

    [documents] Warning fixes and extra error checking

 gdata/services/documents/gdata-documents-service.c |   11 +++++++----
 gdata/tests/documents.c                            |   14 ++++----------
 2 files changed, 11 insertions(+), 14 deletions(-)
---
diff --git a/gdata/services/documents/gdata-documents-service.c b/gdata/services/documents/gdata-documents-service.c
index 2155d44..dfa486d 100644
--- a/gdata/services/documents/gdata-documents-service.c
+++ b/gdata/services/documents/gdata-documents-service.c
@@ -224,6 +224,9 @@ gdata_documents_service_query_single_document (GDataDocumentsService *self, GTyp
 	gchar *resource_id;
 
 	g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self), NULL);
+	g_return_val_if_fail (document_id != 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 (document_type == GDATA_TYPE_DOCUMENTS_FOLDER)
 		resource_id = g_strconcat ("folder:", document_id, NULL);
@@ -529,7 +532,7 @@ gdata_documents_service_upload_document (GDataDocumentsService *self, GDataDocum
 {
 	GDataDocumentsEntry *new_document;
 	SoupMessage *message;
-	gchar *upload_uri, *tmp_str = NULL;
+	gchar *upload_uri;
 
 	g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self), NULL);
 	g_return_val_if_fail (document == NULL || GDATA_IS_DOCUMENTS_ENTRY (document), NULL);
@@ -554,13 +557,13 @@ gdata_documents_service_upload_document (GDataDocumentsService *self, GDataDocum
 	if (folder != NULL) {
 		const gchar *folder_id = gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (folder));
 		g_assert (folder_id != NULL);
-		upload_uri = tmp_str = g_strconcat ("http://docs.google.com/feeds/folders/private/full/folder%3A";, folder_id, NULL);
+		upload_uri = g_strconcat ("http://docs.google.com/feeds/folders/private/full/folder%3A";, folder_id, NULL);
 	} else {
-		upload_uri = "http://docs.google.com/feeds/documents/private/full";;
+		upload_uri = g_strdup ("http://docs.google.com/feeds/documents/private/full";);
 	}
 
 	message = soup_message_new (SOUP_METHOD_POST, upload_uri);
-	g_free (tmp_str);
+	g_free (upload_uri);
 
 	new_document = upload_update_document (self, document, document_file, message, 201, cancellable, error);
 	g_object_unref (message);
diff --git a/gdata/tests/documents.c b/gdata/tests/documents.c
index 345c575..2ffe834 100644
--- a/gdata/tests/documents.c
+++ b/gdata/tests/documents.c
@@ -203,11 +203,9 @@ test_upload_metadata_file (GDataService *service)
 static void
 test_upload_file_get_entry (GDataService *service)
 {
-	GDataDocumentsEntry *new_document;
-	GDataDocumentsPresentation *newly_created_presentation;
+	GDataDocumentsEntry *new_document, *newly_created_presentation;
 	GFile *document_file;
 	GDataCategory *category;
-	GDataDocumentsQuery *query;
 	GError *error = NULL;
 
 	g_assert (service != NULL);
@@ -224,11 +222,11 @@ test_upload_file_get_entry (GDataService *service)
 	newly_created_presentation = gdata_documents_service_query_single_document (GDATA_DOCUMENTS_SERVICE (service), GDATA_TYPE_DOCUMENTS_PRESENTATION,
 										    gdata_documents_entry_get_document_id (new_document), NULL, &error);
 	g_assert_no_error (error);
-	g_assert (GDATA_IS_DOCUMENTS_PRESENTATION (new_document));
-
+	g_assert (GDATA_IS_DOCUMENTS_PRESENTATION (newly_created_presentation));
 
 	g_clear_error (&error);
 	g_object_unref (new_document);
+	g_object_unref (newly_created_presentation);
 	g_object_unref (document_file);
 }
 
@@ -476,7 +474,7 @@ test_download_all_documents (GDataService *service)
 	gchar *destination_file_name;
 	GString *destination_display_name;
 	GList *i;
-	gint ppt_nb = 0, ods_nb = 0, odt_nb = 0;
+	gint ods_nb = 0, odt_nb = 0;
 
 	feed = gdata_documents_service_query_documents (GDATA_DOCUMENTS_SERVICE (service), NULL, NULL, NULL, NULL, &error);
 	g_assert_no_error (error);
@@ -490,8 +488,6 @@ test_download_all_documents (GDataService *service)
 											   TRUE, NULL, &error);
 
 		} else if (GDATA_IS_DOCUMENTS_SPREADSHEET (i->data)) {
-			GFile *destination_file;
-
 			destination_file_name = g_strdup_printf ("/tmp/%s.%s", gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (i->data)), "ods");
 			destination_file = g_file_new_for_path (destination_file_name);
 			g_free (destination_file_name);
@@ -512,8 +508,6 @@ test_download_all_documents (GDataService *service)
 			}
 			g_string_free (destination_display_name, TRUE);
 		} else if (GDATA_IS_DOCUMENTS_TEXT (i->data)) {
-			GFile *destination_file;
-
 			destination_file_name = g_strdup_printf ("/tmp/%s.%s", gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (i->data)), "odt");
 			destination_file = g_file_new_for_path (destination_file_name);
 			g_free (destination_file_name);



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