[libgda] Misc corrections (compiler warnings)



commit 857c56610864650c6118e585c378df73b665267f
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Aug 16 22:12:35 2012 +0200

    Misc corrections (compiler warnings)

 .../data-entries/gdaui-data-cell-renderer-combo.c  |    4 ++--
 libgda-ui/data-entries/gdaui-entry.c               |    2 +-
 libgda/gda-data-model-iter.c                       |    1 -
 libgda/gda-meta-store.c                            |    2 +-
 libgda/gda-meta-struct.c                           |    9 +++++----
 libgda/gda-sql-builder.c                           |    1 -
 libgda/gda-util.c                                  |    2 +-
 libgda/gda-value.c                                 |    2 +-
 libgda/gda-xa-transaction.c                        |    8 ++++----
 libgda/sqlite/gda-sqlite-meta.c                    |    7 ++++---
 libgda/sqlite/virtual/gda-ldap-connection.c        |    2 +-
 providers/mysql/gda-mysql-ddl.c                    |    2 +-
 providers/mysql/gda-mysql-provider.c               |    6 +++++-
 providers/web/gda-web-recordset.c                  |    1 -
 14 files changed, 26 insertions(+), 23 deletions(-)
---
diff --git a/libgda-ui/data-entries/gdaui-data-cell-renderer-combo.c b/libgda-ui/data-entries/gdaui-data-cell-renderer-combo.c
index 48f3f00..ba6152e 100644
--- a/libgda-ui/data-entries/gdaui-data-cell-renderer-combo.c
+++ b/libgda-ui/data-entries/gdaui-data-cell-renderer-combo.c
@@ -463,8 +463,8 @@ gdaui_data_cell_renderer_combo_get_size (GtkCellRenderer *cell,
 					 gint            *width,
 					 gint            *height)
 {
-	gint calc_width;
-	gint calc_height;
+	gint calc_width = 0;
+	gint calc_height = 0;
 
 	/* get the size as calculated by the GtkCellRendererText */
 	GtkCellRendererClass *text_class = g_type_class_peek (GTK_TYPE_CELL_RENDERER_TEXT);
diff --git a/libgda-ui/data-entries/gdaui-entry.c b/libgda-ui/data-entries/gdaui-entry.c
index 2e632ca..121ab58 100644
--- a/libgda-ui/data-entries/gdaui-entry.c
+++ b/libgda-ui/data-entries/gdaui-entry.c
@@ -520,7 +520,7 @@ static void
 delete_text_cb (GtkEditable *editable, gint start_pos, gint end_pos, G_GNUC_UNUSED gpointer data)
 {
 	const gchar *otext = NULL;
-	gint len;
+	gint len = 0;
 	gint nstart = start_pos, nend = end_pos;
 	GdauiEntry *entry = GDAUI_ENTRY (editable);
 
diff --git a/libgda/gda-data-model-iter.c b/libgda/gda-data-model-iter.c
index 8355d9c..03bf543 100644
--- a/libgda/gda-data-model-iter.c
+++ b/libgda/gda-data-model-iter.c
@@ -523,7 +523,6 @@ gda_data_model_iter_set_property (GObject *object,
 	if (iter->priv) {
 		switch (param_id) {
 		case PROP_DATA_MODEL: {
-			gint col, ncols;
 			GdaDataModel *model;
 
 			GObject* ptr = g_value_get_object (value);
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index e551fd2..ff5217d 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -1502,7 +1502,7 @@ static void compute_view_dependencies (GdaMetaStoreClass *klass, GdaMetaStore *s
 static DbObject *
 create_view_object (GdaMetaStoreClass *klass, GdaMetaStore *store, xmlNodePtr node, GError **error)
 {
-	DbObject *dbobj;
+	DbObject *dbobj = NULL;
 	xmlChar *view_name;
 	gchar *complete_obj_name = NULL;
 
diff --git a/libgda/gda-meta-struct.c b/libgda/gda-meta-struct.c
index 21fc766..3902a40 100644
--- a/libgda/gda-meta-struct.c
+++ b/libgda/gda-meta-struct.c
@@ -1121,7 +1121,7 @@ _meta_struct_complement (GdaMetaStruct *mstruct, GdaMetaDbObjectType type,
 			
 			nrows = gda_data_model_get_n_rows (model);
 			for (i = 0; i < nrows; i++) {
-				GdaMetaTableForeignKey *tfk;
+				GdaMetaTableForeignKey *tfk = NULL;
 				const GValue *fk_catalog, *fk_schema, *fk_tname, *fk_name;
 				const GValue *upd_policy, *del_policy;
 
@@ -1176,7 +1176,8 @@ _meta_struct_complement (GdaMetaStruct *mstruct, GdaMetaDbObjectType type,
 				/* FIXME: compute @cols_nb, and all the @*_array members (ref_pk_cols_array must be
 				 * initialized with -1 values everywhere */
 				sql = "SELECT k.column_name, c.ordinal_position FROM _key_column_usage k INNER JOIN _columns c ON (c.table_catalog = k.table_catalog AND c.table_schema = k.table_schema AND c.table_name=k.table_name AND c.column_name=k.column_name) WHERE k.table_catalog = ##tc::string AND k.table_schema = ##ts::string AND k.table_name = ##tname::string AND k.constraint_name = ##cname::string ORDER BY k.ordinal_position";
-				GdaDataModel *fk_cols, *ref_pk_cols;
+				GdaDataModel *fk_cols = NULL;
+				GdaDataModel *ref_pk_cols = NULL;
 				gboolean fkerror = FALSE;
 				cvalue = gda_data_model_get_value_at (model, 3, i, error);
 				if (!cvalue) goto onfkerror;
@@ -1268,8 +1269,8 @@ _meta_struct_complement (GdaMetaStruct *mstruct, GdaMetaDbObjectType type,
 					g_object_unref (fk_cols);
 				if (ref_pk_cols)
 					g_object_unref (ref_pk_cols);
-				
-				mt->fk_list = g_slist_prepend (mt->fk_list, tfk);
+				if (tfk)
+					mt->fk_list = g_slist_prepend (mt->fk_list, tfk);
 				goto onerror;
 			}
 			mt->fk_list = g_slist_reverse (mt->fk_list);
diff --git a/libgda/gda-sql-builder.c b/libgda/gda-sql-builder.c
index 3a69a15..2772524 100644
--- a/libgda/gda-sql-builder.c
+++ b/libgda/gda-sql-builder.c
@@ -823,7 +823,6 @@ gda_sql_builder_add_expr_value (GdaSqlBuilder *builder, G_GNUC_UNUSED GdaDataHan
 	g_return_val_if_fail (GDA_IS_SQL_BUILDER (builder), 0);
 	g_return_val_if_fail (builder->priv->main_stmt, 0);
 
-	gchar *str;
 	GdaSqlExpr *expr;
 	expr = gda_sql_expr_new (NULL);
 	if (value && (G_VALUE_TYPE (value) != GDA_TYPE_NULL)) {
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index 712c37d..964811f 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -675,7 +675,7 @@ gda_utility_holder_load_attributes (GdaHolder *holder, xmlNodePtr node, GSList *
 
 	/* set restricting source if specified */
 	if (str && sources) {
-		gchar *ptr1, *ptr2 = NULL, *tok;
+		gchar *ptr1, *ptr2 = NULL, *tok = NULL;
 		gchar *source;
 			
 		source = g_strdup ((gchar*)str);
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index 7790402..2d865b4 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -2916,7 +2916,7 @@ gda_string_to_binary (const gchar *str)
 	}
 
 	total = strlen (str);
-	retval = g_new0 (gchar, total + 1);
+	retval = g_new0 (guchar, total + 1);
 	sptr = (guchar*) str;
 	rptr = retval;
 
diff --git a/libgda/gda-xa-transaction.c b/libgda/gda-xa-transaction.c
index 6942325..2c9e3c5 100644
--- a/libgda/gda-xa-transaction.c
+++ b/libgda/gda-xa-transaction.c
@@ -468,7 +468,7 @@ gda_xa_transaction_commit (GdaXaTransaction *xa_trans, GSList **cnc_to_recover,
 	 * PREPARE phase 
 	 */
 	for (list = xa_trans->priv->cnc_list; list; list = list->next) {
-		GdaConnection *cnc;
+		GdaConnection *cnc = NULL;
 		GdaServerProvider *prov;
 		const GdaBinary *branch;
 		
@@ -503,7 +503,7 @@ gda_xa_transaction_commit (GdaXaTransaction *xa_trans, GSList **cnc_to_recover,
 	if (list) {
 		/* something went wrong during the PREPARE phase => rollback everything */
 		for (; list; list = list->prev) {
-			GdaConnection *cnc;
+			GdaConnection *cnc = NULL;
 			GdaServerProvider *prov;
 			
 			if (cnc == xa_trans->priv->non_xa_cnc) 
@@ -533,7 +533,7 @@ gda_xa_transaction_commit (GdaXaTransaction *xa_trans, GSList **cnc_to_recover,
 	    ! gda_connection_commit_transaction (xa_trans->priv->non_xa_cnc, NULL, error)) {
 		/* something went wrong => rollback everything */
 		for (list = xa_trans->priv->cnc_list; list; list = list->next) {
-			GdaConnection *cnc;
+			GdaConnection *cnc = NULL;
 			GdaServerProvider *prov;
 			
 			if (cnc == xa_trans->priv->non_xa_cnc)
@@ -557,7 +557,7 @@ gda_xa_transaction_commit (GdaXaTransaction *xa_trans, GSList **cnc_to_recover,
 	}
 
 	for (list = xa_trans->priv->cnc_list; list; list = list->next) {
-		GdaConnection *cnc;
+		GdaConnection *cnc = NULL;
 		GdaServerProvider *prov;
 		const GdaBinary *branch;
 		
diff --git a/libgda/sqlite/gda-sqlite-meta.c b/libgda/sqlite/gda-sqlite-meta.c
index cffc162..f394a21 100644
--- a/libgda/sqlite/gda-sqlite-meta.c
+++ b/libgda/sqlite/gda-sqlite-meta.c
@@ -1610,7 +1610,7 @@ fill_constraints_ref_model (GdaConnection *cnc, G_GNUC_UNUSED SqliteConnectionDa
 		}
 		if ((fkid  == -1) || (fkid != g_value_get_int (cvalue))) {
 			gchar *constname;
-			GValue *v2, *v3, *v4, *v5;
+			GValue *v2, *v3, *v4, *v5 = NULL;
 
 			fkid = g_value_get_int (cvalue);
 
@@ -1896,7 +1896,7 @@ fill_key_columns_model (GdaConnection *cnc, SqliteConnectionData *cdata, GdaData
 		 */
 		GType fk_col_types[] = {G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE};
 		gint fkid = -1;
-		gint ord_pos;
+		gint ord_pos = 1;
 		stmt = get_statement (I_PRAGMA_FK_LIST, schema_name, g_value_get_string (p_table_name), error);
 		tmpmodel = gda_connection_statement_execute_select_full (cnc, stmt, pragma_set, 
 									 GDA_STATEMENT_MODEL_RANDOM_ACCESS, 
@@ -2381,7 +2381,8 @@ _gda_sqlite_meta_index_cols (G_GNUC_UNUSED GdaServerProvider *prov, G_GNUC_UNUSE
 }
 
 /*
- * @...: a list of TRUE/FALSE, GValue*  -- if TRUE then the following GValue must be freed
+ * @...: a list of TRUE/FALSE, GValue*  -- if TRUE then the following GValue will be freed by
+ * this function
  */
 static gboolean 
 append_a_row (GdaDataModel *to_model, GError **error, gint nb, ...)
diff --git a/libgda/sqlite/virtual/gda-ldap-connection.c b/libgda/sqlite/virtual/gda-ldap-connection.c
index 262ca46..a047959 100644
--- a/libgda/sqlite/virtual/gda-ldap-connection.c
+++ b/libgda/sqlite/virtual/gda-ldap-connection.c
@@ -897,7 +897,7 @@ gda_ldap_entry_new (const gchar *dn)
 		entry->dn = g_strdup (dn);
 	entry->attributes_hash = g_hash_table_new (g_str_hash, g_str_equal);
 	entry->nb_attributes = 0;
-	entry->attributes = g_new0 (GdaLdapAttribute, 1);
+	entry->attributes = g_new0 (GdaLdapAttribute*, 1);
 	return entry;
 }
 
diff --git a/providers/mysql/gda-mysql-ddl.c b/providers/mysql/gda-mysql-ddl.c
index d8649ac..c7fd5d9 100644
--- a/providers/mysql/gda-mysql-ddl.c
+++ b/providers/mysql/gda-mysql-ddl.c
@@ -252,7 +252,7 @@ gda_mysql_render_CREATE_TABLE (GdaServerProvider *provider, GdaConnection *cnc,
 		if (node) {
 			nrows = gda_server_operation_get_sequence_size (op, "/FKEY_S");
 			for (i = 0; i < nrows; i++) {
-				gint nbfields, j;
+				gint nbfields = 0, j;
 
 				g_string_append (string, ", FOREIGN KEY (");
 				node = gda_server_operation_get_node_info (op, "/FKEY_S/%d/FKEY_FIELDS_A", i);
diff --git a/providers/mysql/gda-mysql-provider.c b/providers/mysql/gda-mysql-provider.c
index 3fc60db..4087aa4 100644
--- a/providers/mysql/gda-mysql-provider.c
+++ b/providers/mysql/gda-mysql-provider.c
@@ -2571,16 +2571,20 @@ gda_mysql_provider_statement_execute (GdaServerProvider               *provider,
 			}
 		}
 		else {
-			gchar *str;
+			gchar *str = NULL;
 			GdaDataHandler *data_handler =
 				gda_server_provider_get_data_handler_g_type (provider, cnc, 
 									     G_VALUE_TYPE (value));
 			if (data_handler == NULL) {
 				/* there is an error here */
+				str = g_strdup_printf(_("Unhandled data type '%s', please report this bug to "
+							"http://bugzilla.gnome.org/ for the \"libgda\" product."),
+						      gda_g_type_to_string (G_VALUE_TYPE (value)));
 				event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
 				gda_connection_event_set_description (event, str);
 				g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
 					     GDA_SERVER_PROVIDER_DATA_ERROR, "%s", str);
+				g_free (str);
 				break;
 			}
 			else {
diff --git a/providers/web/gda-web-recordset.c b/providers/web/gda-web-recordset.c
index ebbf5ca..abc5768 100644
--- a/providers/web/gda-web-recordset.c
+++ b/providers/web/gda-web-recordset.c
@@ -143,7 +143,6 @@ gda_web_recordset_new (GdaConnection *cnc, GdaWebPStmt *ps, GdaSet *exec_params,
 {
 	GdaWebRecordset *model;
         gint i;
-	static guint counter = 0;
 	WebConnectionData *cdata;
 
         g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);



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