[tracker] libtracker-data: Make tracker_ontology_[write|load]_gvdb return a boolean



commit 385a7d4418365c51ccf0dd58f2520eaff4a8cd34
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Jan 28 12:50:22 2017 +0100

    libtracker-data: Make tracker_ontology_[write|load]_gvdb return a boolean
    
    Those return a GError already, so returning a boolean too sounds consistent
    with GLib APIs. Coincidentally fixes an "Unchecked return value" Coverity
    warning with gvdb_table_write_contents(), we now do propagate it.
    
    Coverity ID: 1188424

 src/libtracker-data/tracker-data-manager.c |    7 +++++--
 src/libtracker-data/tracker-ontologies.c   |   12 ++++++++----
 src/libtracker-data/tracker-ontologies.h   |    4 ++--
 3 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 9de0213..2674aed 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3559,10 +3559,11 @@ tracker_data_manager_reload (TrackerBusyCallback   busy_callback,
        return status;
 }
 
-static void
+static gboolean
 write_ontologies_gvdb (gboolean   overwrite,
                        GError   **error)
 {
+       gboolean retval = TRUE;
        gchar *filename;
 
        filename = g_build_filename (g_get_user_cache_dir (),
@@ -3571,10 +3572,12 @@ write_ontologies_gvdb (gboolean   overwrite,
                                     NULL);
 
        if (overwrite || !g_file_test (filename, G_FILE_TEST_EXISTS)) {
-               tracker_ontologies_write_gvdb (filename, error);
+               retval = tracker_ontologies_write_gvdb (filename, error);
        }
 
        g_free (filename);
+
+       return retval;
 }
 
 static void
diff --git a/src/libtracker-data/tracker-ontologies.c b/src/libtracker-data/tracker-ontologies.c
index 118e901..3926a59 100644
--- a/src/libtracker-data/tracker-ontologies.c
+++ b/src/libtracker-data/tracker-ontologies.c
@@ -480,13 +480,14 @@ gvdb_hash_table_insert_statement (GHashTable  *table,
        gvdb_hash_table_insert_variant (table, parent, uri, predicate, g_variant_new_string (value));
 }
 
-void
+gboolean
 tracker_ontologies_write_gvdb (const gchar  *filename,
                                GError      **error)
 {
        GHashTable *root_table, *table;
        GvdbItem *root, *item;
        const gchar *uri;
+       gboolean retval;
        gint i;
 
        root_table = gvdb_hash_table_new (NULL, NULL);
@@ -575,12 +576,14 @@ tracker_ontologies_write_gvdb (const gchar  *filename,
        }
        g_hash_table_unref (table);
 
-       gvdb_table_write_contents (root_table, filename, FALSE, error);
+       retval = gvdb_table_write_contents (root_table, filename, FALSE, error);
 
        g_hash_table_unref (root_table);
+
+       return retval;
 }
 
-void
+gboolean
 tracker_ontologies_load_gvdb (const gchar  *filename,
                               GError      **error)
 {
@@ -590,12 +593,13 @@ tracker_ontologies_load_gvdb (const gchar  *filename,
 
        gvdb_table = gvdb_table_new (filename, TRUE, error);
        if (!gvdb_table) {
-               return;
+               return FALSE;
        }
 
        gvdb_namespaces_table = gvdb_table_get_table (gvdb_table, "namespaces");
        gvdb_classes_table = gvdb_table_get_table (gvdb_table, "classes");
        gvdb_properties_table = gvdb_table_get_table (gvdb_table, "properties");
+       return TRUE;
 }
 
 GVariant *
diff --git a/src/libtracker-data/tracker-ontologies.h b/src/libtracker-data/tracker-ontologies.h
index a0f7668..1feefbe 100644
--- a/src/libtracker-data/tracker-ontologies.h
+++ b/src/libtracker-data/tracker-ontologies.h
@@ -60,9 +60,9 @@ const gchar*       tracker_ontologies_get_uri_by_id        (gint              id
 void               tracker_ontologies_add_id_uri_pair      (gint              id,
                                                             const gchar      *uri);
 
-void               tracker_ontologies_write_gvdb           (const gchar      *filename,
+gboolean           tracker_ontologies_write_gvdb           (const gchar      *filename,
                                                             GError          **error);
-void               tracker_ontologies_load_gvdb            (const gchar      *filename,
+gboolean           tracker_ontologies_load_gvdb            (const gchar      *filename,
                                                             GError          **error);
 GVariant *         tracker_ontologies_get_namespace_value_gvdb  (const gchar      *uri,
                                                                  const gchar      *predicate);


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