[libgda] vconnection-hub: fixed bug on namespace check



commit 195dcefb5168d917f92a80fd8cd43e4b9b776ded
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Mon Feb 18 09:58:51 2019 -0600

    vconnection-hub: fixed bug on namespace check
    
    Fixed other minor warnings.

 libgda/gda-connection.c                     | 167 ++++++++++++++--------------
 libgda/gda-data-model-select.c              |   6 +-
 libgda/gda-meta-store.c                     |  14 +--
 libgda/gda-set.c                            |   4 +-
 libgda/sqlite/virtual/gda-vconnection-hub.c |   4 +-
 tests/providers/prov-test-common.c          |  13 +--
 6 files changed, 102 insertions(+), 106 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 8a993075c..e45b48f10 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -4711,100 +4711,101 @@ typedef struct {
        GHashTable         *context_templates_hash;
 } DownstreamCallbackData;
 
-static GError *
-suggest_update_cb_downstream (G_GNUC_UNUSED GdaMetaStore *store, GdaMetaContext *suggest, 
DownstreamCallbackData *data)
-{
-#define MAX_CONTEXT_SIZE 10
-       if (data->error)
-               return data->error;
-
-       GdaMetaContext *templ_context;
-       GdaMetaContext loc_suggest;
-       gchar *column_names[MAX_CONTEXT_SIZE];
-       GValue *column_values[MAX_CONTEXT_SIZE];
+// UNUSED METHOD
+/* static GError * */
+/* suggest_update_cb_downstream (G_GNUC_UNUSED GdaMetaStore *store, GdaMetaContext *suggest, 
DownstreamCallbackData *data) */
+/* { */
+/* #define MAX_CONTEXT_SIZE 10 */
+/*     if (data->error) */
+/*             return data->error; */
+
+/*     GdaMetaContext *templ_context; */
+/*     GdaMetaContext loc_suggest; */
+/*     gchar *column_names[MAX_CONTEXT_SIZE]; */
+/*     GValue *column_values[MAX_CONTEXT_SIZE]; */
 
        /* if there is no context with the same table name in the templates, then exit right now */
-       templ_context = g_hash_table_lookup (data->context_templates_hash, suggest->table_name);
-       if (!templ_context)
-               return NULL;
+/*     templ_context = g_hash_table_lookup (data->context_templates_hash, suggest->table_name); */
+/*     if (!templ_context) */
+/*             return NULL; */
        
-       if (templ_context->size > 0) {
+/*     if (templ_context->size > 0) { */
                /* setup @loc_suggest */
-               gint i, j;
-
-               if (suggest->size > MAX_CONTEXT_SIZE) {
-                       g_warning ("Internal limitation at %s(), limitation should be at least %d, please 
report a bug",
-                                  __FUNCTION__, suggest->size);
-                       return NULL;
-               }
-               loc_suggest.size = suggest->size;
-               loc_suggest.table_name = suggest->table_name;
-               loc_suggest.column_names = column_names;
-               loc_suggest.column_values = column_values;
-               memcpy (loc_suggest.column_names, suggest->column_names, sizeof (gchar *) * suggest->size); 
/* Flawfinder: ignore */
-               memcpy (loc_suggest.column_values, suggest->column_values, sizeof (GValue *) * 
suggest->size); /* Flawfinder: ignore */
+/*             gint i, j; */
+
+/*             if (suggest->size > MAX_CONTEXT_SIZE) { */
+/*                     g_warning ("Internal limitation at %s(), limitation should be at least %d, please 
report a bug", */
+/*                                __FUNCTION__, suggest->size); */
+/*                     return NULL; */
+/*             } */
+/*             loc_suggest.size = suggest->size; */
+/*             loc_suggest.table_name = suggest->table_name; */
+/*             loc_suggest.column_names = column_names; */
+/*             loc_suggest.column_values = column_values; */
+/*             memcpy (loc_suggest.column_names, suggest->column_names, sizeof (gchar *) * suggest->size);  
*/ /* Flawfinder: ignore */
+/*             memcpy (loc_suggest.column_values, suggest->column_values, sizeof (GValue *) * 
suggest->size);  */ /* Flawfinder: ignore */
                
                /* check that any @suggest's columns which is in @templ_context's has the same values */
-               for (j = 0; j < suggest->size; j++) {
-                       for (i = 0; i < templ_context->size; i++) {
-                               if (!strcmp (templ_context->column_names[i], suggest->column_names[j])) {
+/*             for (j = 0; j < suggest->size; j++) { */
+/*                     for (i = 0; i < templ_context->size; i++) { */
+/*                             if (!strcmp (templ_context->column_names[i], suggest->column_names[j])) { */
                                        /* same column name, now check column value */
-                                       if (G_VALUE_TYPE (templ_context->column_values[i]) != 
-                                           G_VALUE_TYPE (suggest->column_values[j])) {
-                                               g_warning ("Internal error: column types mismatch for 
GdaMetaContext "
-                                                          "table '%s' and column '%s' (%s/%s)",
-                                                          templ_context->table_name, 
templ_context->column_names[i], 
-                                                          g_type_name (G_VALUE_TYPE 
(templ_context->column_values[i])),
-                                                          g_type_name (G_VALUE_TYPE 
(suggest->column_values[j])));
-                                               return NULL;
-                                       }
-                                       if (gda_value_compare (templ_context->column_values[i], 
suggest->column_values[j]))
+/*                                     if (G_VALUE_TYPE (templ_context->column_values[i]) !=  */
+/*                                         G_VALUE_TYPE (suggest->column_values[j])) { */
+/*                                             g_warning ("Internal error: column types mismatch for 
GdaMetaContext " */
+/*                                                        "table '%s' and column '%s' (%s/%s)", */
+/*                                                        templ_context->table_name, 
templ_context->column_names[i],  */
+/*                                                        g_type_name (G_VALUE_TYPE 
(templ_context->column_values[i])), */
+/*                                                        g_type_name (G_VALUE_TYPE 
(suggest->column_values[j]))); */
+/*                                             return NULL; */
+/*                                     } */
+/*                                     if (gda_value_compare (templ_context->column_values[i], 
suggest->column_values[j])) */
                                                /* different values */
-                                               return NULL;
-                                       break;
-                               }
-                       }
-               }
+/*                                             return NULL; */
+/*                                     break; */
+/*                             } */
+/*                     } */
+/*             } */
 
                /* @templ_context may contain some more columns => add them to @loc_suggest */
-               for (i = 0; i < templ_context->size; i++) {
-                       for (j = 0; j < suggest->size; j++) {
-                               if (!strcmp (templ_context->column_names[i], suggest->column_names[j])) {
-                                       j = -1;
-                                       break;
-                               }
-                       }
-                       if (j >= 0) {
-                               if (loc_suggest.size >= MAX_CONTEXT_SIZE) {
-                                       g_warning ("Internal limitation at %s(), limitation should be at 
least %d, please report a bug",
-                                                  __FUNCTION__, loc_suggest.size + 1);
-                                       return NULL;
-                               }
-                               loc_suggest.column_names [loc_suggest.size] = templ_context->column_names [i];
-                               loc_suggest.column_values [loc_suggest.size] = templ_context->column_values 
[i];
-                               loc_suggest.size ++;
-                       }
-               }
-
-               suggest = &loc_suggest;
-       }
+/*             for (i = 0; i < templ_context->size; i++) { */
+/*                     for (j = 0; j < suggest->size; j++) { */
+/*                             if (!strcmp (templ_context->column_names[i], suggest->column_names[j])) { */
+/*                                     j = -1; */
+/*                                     break; */
+/*                             } */
+/*                     } */
+/*                     if (j >= 0) { */
+/*                             if (loc_suggest.size >= MAX_CONTEXT_SIZE) { */
+/*                                     g_warning ("Internal limitation at %s(), limitation should be at 
least %d, please report a bug", */
+/*                                                __FUNCTION__, loc_suggest.size + 1); */
+/*                                     return NULL; */
+/*                             } */
+/*                             loc_suggest.column_names [loc_suggest.size] = templ_context->column_names 
[i]; */
+/*                             loc_suggest.column_values [loc_suggest.size] = templ_context->column_values 
[i]; */
+/*                             loc_suggest.size ++; */
+/*                     } */
+/*             } */
+
+/*             suggest = &loc_suggest; */
+/*     } */
        
-       GError *lerror = NULL;
-       if (!local_meta_update (data->prov, data->cnc, suggest, &lerror)) {
-               if (lerror)
-                       data->error = lerror;
-               else {
-                       g_set_error (&lerror,GDA_CONNECTION_ERROR,
-                                    GDA_CONNECTION_META_DATA_CONTEXT_ERROR,
-                                     "%s", _("Meta update error"));
-                       data->error = lerror;
-               }
-
-               return data->error;
-       }
-
-       return NULL;
-}
+/*     GError *lerror = NULL; */
+/*     if (!local_meta_update (data->prov, data->cnc, suggest, &lerror)) { */
+/*             if (lerror) */
+/*                     data->error = lerror; */
+/*             else { */
+/*                     g_set_error (&lerror,GDA_CONNECTION_ERROR, */
+/*                                  GDA_CONNECTION_META_DATA_CONTEXT_ERROR, */
+/*                                   "%s", _("Meta update error")); */
+/*                     data->error = lerror; */
+/*             } */
+
+/*             return data->error; */
+/*     } */
+
+/*     return NULL; */
+/* } */
 
 /**
  * gda_connection_update_meta_store:
diff --git a/libgda/gda-data-model-select.c b/libgda/gda-data-model-select.c
index e8a4d59be..bb23ef37d 100644
--- a/libgda/gda-data-model-select.c
+++ b/libgda/gda-data-model-select.c
@@ -243,7 +243,8 @@ gda_data_model_select_new_from_string (GdaConnection *cnc, const gchar *sql)
 gboolean
 gda_data_model_select_is_valid (GdaDataModelSelect *model)
 {
-  g_return_if_fail (model);
+  g_return_val_if_fail (model != NULL, FALSE);
+  g_return_val_if_fail (GDA_IS_DATA_MODEL_SELECT (model), FALSE);
   GdaDataModelSelectPrivate *priv = gda_data_model_select_get_instance_private (GDA_DATA_MODEL_SELECT 
(model));
   return priv->model != NULL;
 }
@@ -257,7 +258,8 @@ gda_data_model_select_is_valid (GdaDataModelSelect *model)
 GdaSet*
 gda_data_model_select_get_parameters  (GdaDataModelSelect *model)
 {
-  g_return_if_fail (model);
+  g_return_val_if_fail (model != NULL, NULL);
+  g_return_val_if_fail (GDA_IS_CONNECTION (model), NULL);
   GdaDataModelSelectPrivate *priv = gda_data_model_select_get_instance_private (GDA_DATA_MODEL_SELECT 
(model));
   if (priv->params == NULL) {
     gda_statement_get_parameters (priv->stm, &priv->params, NULL);
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index 46d94c494..8273558cf 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -1587,23 +1587,23 @@ create_db_objects (GdaMetaStoreClass *klass, GdaMetaStore *store)
        /* load information schema's structure XML file */
        ostream = g_memory_output_stream_new_resizable ();
        res = g_file_new_for_uri ("resource:///libgda/information_schema.xml");
-       istream = g_file_read (res, NULL, lerror);
+       istream = G_INPUT_STREAM (g_file_read (res, NULL, &lerror));
        if (istream == NULL) {
                g_warning (_("Internal error: no information schema was found: %s"),
                                                         lerror && lerror->message ? lerror->message : "No 
error message was set");
-               g_clear_error (lerror);
+               g_clear_error (&lerror);
                return;
        }
-       g_clear_error (lerror);
-       size = g_output_stream_splice (ostream, istream, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE, NULL, lerror);
+       g_clear_error (&lerror);
+       size = g_output_stream_splice (ostream, istream, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE, NULL, &lerror);
        if (size == -1) {
                g_warning (_("Internal error: can't read information schema: %s"),
                                                         lerror && lerror->message ? lerror->message : "No 
error message was set");
-               g_clear_error (lerror);
+               g_clear_error (&lerror);
                return;
        }
-       g_clear_error (lerror);
-       schema = (gchar*) g_memory_output_stream_get_data (ostream);
+       g_clear_error (&lerror);
+       schema = (gchar*) g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (ostream));
        doc = xmlReadDoc (schema, "", NULL, XML_PARSE_RECOVER);
        g_object_unref (ostream);
        g_object_unref (istream);
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index 3146f4e76..a1f36b021 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -1883,14 +1883,14 @@ holder_notify_cb (GdaHolder *holder, GParamSpec *pspec, GdaSet *dataset)
        }
        else if (!strcmp (pspec->name, "name")) {
                GValue *name = gda_value_new (G_TYPE_STRING);
-               g_object_get_property (dataset, "name", name);
+               g_object_get_property (G_OBJECT (dataset), "name", name);
                g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder,
                                     "name", name);
                gda_value_free (name);
        }
        else if (!strcmp (pspec->name, "description")) {
                GValue *desc = gda_value_new (G_TYPE_STRING);
-               g_object_get_property (dataset, "description", desc);
+               g_object_get_property (G_OBJECT (dataset), "description", desc);
                g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder,
                                     "description", desc);
                gda_value_free (desc);
diff --git a/libgda/sqlite/virtual/gda-vconnection-hub.c b/libgda/sqlite/virtual/gda-vconnection-hub.c
index 5478dec5c..a4311e9ce 100644
--- a/libgda/sqlite/virtual/gda-vconnection-hub.c
+++ b/libgda/sqlite/virtual/gda-vconnection-hub.c
@@ -171,7 +171,7 @@ gda_vconnection_hub_add (GdaVconnectionHub *hub,
        g_return_val_if_fail (GDA_IS_VCONNECTION_HUB (hub), FALSE);
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 
-       if (hc == NULL) {
+       if (ns == NULL) {
                g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
                             GDA_SERVER_PROVIDER_MISUSE_ERROR,
                             "%s", _("Namespace must be specified"));
@@ -763,7 +763,7 @@ dict_table_create_model_func (GdaVconnectionDataModelSpec *spec, G_GNUC_UNUSED i
        if (idxStr) {
                gint i;
                GSList *list;
-               stmt = GDA_STATEMENT (idxStr);
+               stmt = GDA_STATEMENT ((GdaStatement*) idxStr);
                g_assert (GDA_IS_STATEMENT (stmt));
                if (! gda_statement_get_parameters (stmt, &params, NULL))
                        return NULL;
diff --git a/tests/providers/prov-test-common.c b/tests/providers/prov-test-common.c
index b209fe670..a5d527a73 100644
--- a/tests/providers/prov-test-common.c
+++ b/tests/providers/prov-test-common.c
@@ -47,9 +47,6 @@ prov_test_common_setup (void)
        int number_failed = 0;
        GError *error = NULL;
        GdaServerOperation *opndb;
-       GdaConnection *cnct = NULL;
-       gchar **env = NULL;
-       const gchar *cnc_string = NULL;
 
 #ifdef CHECK_EXTRA_INFO
        g_print ("\n============= %s() =============\n", __FUNCTION__);
@@ -212,11 +209,10 @@ prov_test_common_check_meta_partial (void)
 {
        int number_failed = 0;
        GSList *tables = NULL, *list;
-       gboolean dump_ok = TRUE;
        GdaMetaStore *store;
        gchar **dump1 = NULL;
        GError *gerror = NULL;
-       gint ntables, i;
+       gint i;
 
        store = gda_connection_get_meta_store (cnc);
 
@@ -313,11 +309,10 @@ prov_test_common_check_meta_partial2 (void)
 {
        int number_failed = 0;
        GSList *tables = NULL, *list;
-       gboolean dump_ok = TRUE;
        GdaMetaStore *store;
        gchar **dump1 = NULL;
        GError *gerror = NULL;
-       gint ntables, i;
+       gint i;
 
        store = gda_connection_get_meta_store (cnc);
 
@@ -416,11 +411,10 @@ prov_test_common_check_meta_partial3 (void)
 {
        int number_failed = 0;
        GSList *tables = NULL, *list;
-       gboolean dump_ok = TRUE;
        GdaMetaStore *store;
        gchar **dump1 = NULL;
        GError *gerror = NULL;
-       gint ntables, i;
+       gint i;
 
        store = gda_connection_get_meta_store (cnc);
 
@@ -902,7 +896,6 @@ prov_test_common_check_data_select (void)
        GError *error = NULL;
        int number_failed = 0;
        GdaDataModel *model = NULL;
-       const gchar *remain;
        GSList *columns;
        gint i, ncols;
 


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