[libgda] More corrections after running cppcheck
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] More corrections after running cppcheck
- Date: Wed, 13 Oct 2010 15:22:44 +0000 (UTC)
commit 57801e0889fb8e2a5febad880ad0ea326d43deb3
Author: Vivien Malerba <malerba gnome-db org>
Date: Wed Oct 13 17:17:15 2010 +0200
More corrections after running cppcheck
libgda/binreloc/gda-binreloc.c | 4 +++-
libgda/gda-data-model.c | 3 ++-
libgda/gda-server-provider-extra.c | 2 +-
libgda/gda-util.c | 4 ----
libgda/sql-parser/parser.y | 2 +-
libgda/sqlite/virtual/gda-vprovider-data-model.c | 2 +-
providers/firebird/parser.y | 2 +-
providers/oracle/parser.y | 2 +-
providers/reuseable/mysql/parser.y | 2 +-
providers/reuseable/postgres/parser.y | 2 +-
providers/skel-implementation/capi/parser.y | 2 +-
samples/XSLT/transform.c | 2 +-
tests/meta-store/common.c | 3 +--
tests/test-cnc-utils.c | 2 +-
14 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/libgda/binreloc/gda-binreloc.c b/libgda/binreloc/gda-binreloc.c
index 809ec17..055746e 100644
--- a/libgda/binreloc/gda-binreloc.c
+++ b/libgda/binreloc/gda-binreloc.c
@@ -229,8 +229,10 @@ gda_gbr_get_file_path (GdaPrefixDir where, ...)
#endif
}
- if (!prefix || !*prefix)
+ if (!prefix || !*prefix) {
+ g_free (prefix);
return NULL;
+ }
/* filename part */
size = 10;
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 3619c78..52ea1e3 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -1155,7 +1155,8 @@ gda_data_model_export_to_string (GdaDataModel *model, GdaDataModelIOFormat forma
g_string_append_c (retstring, quote);
}
g_string_append_c (retstring, '\n');
- g_free (rcols);
+ if (!cols)
+ g_free (rcols);
}
}
else
diff --git a/libgda/gda-server-provider-extra.c b/libgda/gda-server-provider-extra.c
index 765fdc7..412b5e4 100644
--- a/libgda/gda-server-provider-extra.c
+++ b/libgda/gda-server-provider-extra.c
@@ -112,7 +112,7 @@ GdaDataHandler *
gda_server_provider_get_data_handler_default (GdaServerProvider *provider, G_GNUC_UNUSED GdaConnection *cnc,
GType type, G_GNUC_UNUSED const gchar *dbms_type)
{
- GdaDataHandler *dh;
+ GdaDataHandler *dh = NULL;
if ((type == G_TYPE_INT64) ||
(type == G_TYPE_UINT64) ||
(type == G_TYPE_DOUBLE) ||
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index a8cf6f4..d66b8c4 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -1071,8 +1071,6 @@ gda_compute_dml_statements (GdaConnection *cnc, GdaStatement *select_stmt, gbool
continue;
g_hash_table_insert (fields_hash, selfield->field_name, GINT_TO_POINTER (1));
- gchar *str;
- str = gda_sql_identifier_quote (selfield->field_name, cnc, NULL, FALSE, FALSE);
if (insert_stmt) {
GdaSqlField *field;
field = gda_sql_field_new (GDA_SQL_ANY_PART (ist));
@@ -1109,8 +1107,6 @@ gda_compute_dml_statements (GdaConnection *cnc, GdaStatement *select_stmt, gbool
expr->param_spec = pspec;
ust->expr_list = g_slist_append (ust->expr_list, expr);
}
-
- g_free (str);
}
g_hash_table_destroy (fields_hash);
diff --git a/libgda/sql-parser/parser.y b/libgda/sql-parser/parser.y
index 45de76d..d675ac3 100644
--- a/libgda/sql-parser/parser.y
+++ b/libgda/sql-parser/parser.y
@@ -206,7 +206,7 @@ create_uni_expr (GdaSqlOperatorType op, GdaSqlExpr *expr) {
static GdaSqlStatement *
compose_multiple_compounds (GdaSqlStatementCompoundType ctype, GdaSqlStatement *left, GdaSqlStatement *right) {
- GdaSqlStatement *ret;
+ GdaSqlStatement *ret = NULL;
GdaSqlStatementCompound *lc = (GdaSqlStatementCompound*) left->contents;
if (lc->compound_type == ctype) {
GdaSqlStatementCompound *rc = (GdaSqlStatementCompound*) right->contents;
diff --git a/libgda/sqlite/virtual/gda-vprovider-data-model.c b/libgda/sqlite/virtual/gda-vprovider-data-model.c
index 222a158..aca2551 100644
--- a/libgda/sqlite/virtual/gda-vprovider-data-model.c
+++ b/libgda/sqlite/virtual/gda-vprovider-data-model.c
@@ -583,7 +583,7 @@ virtualOpen (sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor)
cursor = g_new0 (VirtualCursor, 1);
cursor->iter = gda_data_model_create_iter (vtable->wrapper);
cursor->ncols = gda_data_model_get_n_columns (GDA_DATA_MODEL (vtable->td->real_model));
- *ppCursor = &(cursor->base);
+ *ppCursor = (sqlite3_vtab_cursor*) cursor;
return SQLITE_OK;
}
diff --git a/providers/firebird/parser.y b/providers/firebird/parser.y
index 6c4ecb3..5569c79 100644
--- a/providers/firebird/parser.y
+++ b/providers/firebird/parser.y
@@ -206,7 +206,7 @@ create_uni_expr (GdaSqlOperatorType op, GdaSqlExpr *expr) {
static GdaSqlStatement *
compose_multiple_compounds (GdaSqlStatementCompoundType ctype, GdaSqlStatement *left, GdaSqlStatement *right) {
- GdaSqlStatement *ret;
+ GdaSqlStatement *ret = NULL;
GdaSqlStatementCompound *lc = (GdaSqlStatementCompound*) left->contents;
if (lc->compound_type == ctype) {
GdaSqlStatementCompound *rc = (GdaSqlStatementCompound*) right->contents;
diff --git a/providers/oracle/parser.y b/providers/oracle/parser.y
index 1df4145..cdd7390 100644
--- a/providers/oracle/parser.y
+++ b/providers/oracle/parser.y
@@ -206,7 +206,7 @@ create_uni_expr (GdaSqlOperatorType op, GdaSqlExpr *expr) {
static GdaSqlStatement *
compose_multiple_compounds (GdaSqlStatementCompoundType ctype, GdaSqlStatement *left, GdaSqlStatement *right) {
- GdaSqlStatement *ret;
+ GdaSqlStatement *ret = NULL;
GdaSqlStatementCompound *lc = (GdaSqlStatementCompound*) left->contents;
if (lc->compound_type == ctype) {
GdaSqlStatementCompound *rc = (GdaSqlStatementCompound*) right->contents;
diff --git a/providers/reuseable/mysql/parser.y b/providers/reuseable/mysql/parser.y
index d98c080..fea08ee 100644
--- a/providers/reuseable/mysql/parser.y
+++ b/providers/reuseable/mysql/parser.y
@@ -206,7 +206,7 @@ create_uni_expr (GdaSqlOperatorType op, GdaSqlExpr *expr) {
static GdaSqlStatement *
compose_multiple_compounds (GdaSqlStatementCompoundType ctype, GdaSqlStatement *left, GdaSqlStatement *right) {
- GdaSqlStatement *ret;
+ GdaSqlStatement *ret = NULL;
GdaSqlStatementCompound *lc = (GdaSqlStatementCompound*) left->contents;
if (lc->compound_type == ctype) {
GdaSqlStatementCompound *rc = (GdaSqlStatementCompound*) right->contents;
diff --git a/providers/reuseable/postgres/parser.y b/providers/reuseable/postgres/parser.y
index 4022c93..81f096e 100644
--- a/providers/reuseable/postgres/parser.y
+++ b/providers/reuseable/postgres/parser.y
@@ -206,7 +206,7 @@ create_uni_expr (GdaSqlOperatorType op, GdaSqlExpr *expr) {
static GdaSqlStatement *
compose_multiple_compounds (GdaSqlStatementCompoundType ctype, GdaSqlStatement *left, GdaSqlStatement *right) {
- GdaSqlStatement *ret;
+ GdaSqlStatement *ret = NULL;
GdaSqlStatementCompound *lc = (GdaSqlStatementCompound*) left->contents;
if (lc->compound_type == ctype) {
GdaSqlStatementCompound *rc = (GdaSqlStatementCompound*) right->contents;
diff --git a/providers/skel-implementation/capi/parser.y b/providers/skel-implementation/capi/parser.y
index 4444ade..744022c 100644
--- a/providers/skel-implementation/capi/parser.y
+++ b/providers/skel-implementation/capi/parser.y
@@ -206,7 +206,7 @@ create_uni_expr (GdaSqlOperatorType op, GdaSqlExpr *expr) {
static GdaSqlStatement *
compose_multiple_compounds (GdaSqlStatementCompoundType ctype, GdaSqlStatement *left, GdaSqlStatement *right) {
- GdaSqlStatement *ret;
+ GdaSqlStatement *ret = NULL;
GdaSqlStatementCompound *lc = (GdaSqlStatementCompound*) left->contents;
if (lc->compound_type == ctype) {
GdaSqlStatementCompound *rc = (GdaSqlStatementCompound*) right->contents;
diff --git a/samples/XSLT/transform.c b/samples/XSLT/transform.c
index 9ef7d75..49bf1e0 100644
--- a/samples/XSLT/transform.c
+++ b/samples/XSLT/transform.c
@@ -96,7 +96,7 @@ main (int argc, char *argv[])
static int
sqlxslt_process_xslt_file_ext (GdaXsltExCont *sql_ctx, const char *inputFile,
const char *xslFileName, const char *outputFileName) {
- int ret;
+ int ret = 0;
xmlDocPtr doc,res;
xsltStylesheetPtr xsltdoc;
xsltTransformContextPtr ctxt;
diff --git a/tests/meta-store/common.c b/tests/meta-store/common.c
index 16e885f..1818bea 100644
--- a/tests/meta-store/common.c
+++ b/tests/meta-store/common.c
@@ -108,8 +108,7 @@ meta_changed_cb (GdaMetaStore *store, GSList *changes, gpointer data)
}
if (expected_changes) {
/* expected more changes */
- el = expected_changes;
- gchar *estr = (gchar *) el->data;
+ gchar *estr = (gchar *) expected_changes->data;
g_print ("Received no change but EXPECTED GdaMetaStoreChange: %s", estr);
exit (EXIT_FAILURE);
}
diff --git a/tests/test-cnc-utils.c b/tests/test-cnc-utils.c
index 3e2c6d3..7ef7da7 100644
--- a/tests/test-cnc-utils.c
+++ b/tests/test-cnc-utils.c
@@ -329,7 +329,7 @@ test_cnc_setup_db_contents (G_GNUC_UNUSED GdaConnection *cnc, G_GNUC_UNUSED cons
gboolean
test_cnc_load_data_from_file (GdaConnection *cnc, const gchar *table, const gchar *full_file, GError **error)
{
- GdaStatement *stmt;
+ GdaStatement *stmt = NULL;
GdaSet *params = NULL;
GdaDataModel *import;
gint nrows, ncols, i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]