2011.08.21 23:02, Christian Stimming rašė:
Dear Aurimas,

thank you very much for your patches. The code looks very good and those
patches are surely an improvement. I've committed them all to SVN trunk.

As John already said, submitting patches to bugzilla is another possibility.
For single patches (especially non-trivial ones) we think this is the best way
to handle them. However, downloading a series of patches from bugzilla
attachments is somewhat inconvenient, so I also see some value in just sending
them here as email attachments. Hm... I'm unsure whether it is important to
state a general rule here. Whatever.

Thanks for the code!


Hello,
I personally think that for trivial patches it is too much unnecessary work to submit them to bugzilla.

Here are some more patches fixing errors detected by cppcheck.

Aurimas
>From 1717fb8f144f6a9c779ced7fedcc7cb80a84331b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aurimas=20Fi=C5=A1eras?= <[email protected]>
Date: Sat, 27 Aug 2011 12:59:25 +0300
Subject: (cppcheck) Fix several memory leaks

---
 src/html/gnc-html-graph-gog-webkit.c |    5 +++++
 src/html/gnc-html-webkit.c           |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/html/gnc-html-graph-gog-webkit.c b/src/html/gnc-html-graph-gog-webkit.c
index 91a5f4b..03a6b4c 100644
--- a/src/html/gnc-html-graph-gog-webkit.c
+++ b/src/html/gnc-html-graph-gog-webkit.c
@@ -249,6 +249,7 @@ handle_piechart( GncHtml* html, gpointer eb, gpointer d )
     if ( temp_str != NULL )
     {
         pieChartInfo.data = read_doubles( temp_str, pieChartInfo.datasize );
+        g_free( temp_str );
     }
     temp_str = get_string_param( &object_info, "colors" );
     if ( temp_str != NULL )
@@ -314,6 +315,7 @@ handle_barchart( GncHtml* html, gpointer eb, gpointer d )
     if ( temp_str != NULL )
     {
         barChartInfo.data = read_doubles( temp_str, barChartInfo.data_rows * barChartInfo.data_cols );
+        g_free( temp_str );
     }
     barChartInfo.x_axis_label = get_string_param( &object_info, "x_axis_label" );
     barChartInfo.y_axis_label = get_string_param( &object_info, "y_axis_label" );
@@ -394,6 +396,7 @@ handle_linechart( GncHtml* html, gpointer eb, gpointer d )
     if ( temp_str != NULL )
     {
         lineChartInfo.data = read_doubles( temp_str, lineChartInfo.data_rows * lineChartInfo.data_cols );
+        g_free( temp_str );
     }
     lineChartInfo.x_axis_label = get_string_param( &object_info, "x_axis_label" );
     lineChartInfo.y_axis_label = get_string_param( &object_info, "y_axis_label" );
@@ -465,11 +468,13 @@ handle_scatter( GncHtml* html, gpointer eb, gpointer d )
     if ( temp_str != NULL )
     {
         scatterPlotInfo.xData = read_doubles( temp_str, scatterPlotInfo.datasize );
+        g_free( temp_str );
     }
     temp_str = get_string_param( &object_info, "y_data" );
     if ( temp_str != NULL )
     {
         scatterPlotInfo.yData = read_doubles( temp_str, scatterPlotInfo.datasize );
+        g_free( temp_str );
     }
 
     pixbuf = gnc_html_graph_gog_create_scatterplot( &scatterPlotInfo );
diff --git a/src/html/gnc-html-webkit.c b/src/html/gnc-html-webkit.c
index 4b4bef2..90a058c 100644
--- a/src/html/gnc-html-webkit.c
+++ b/src/html/gnc-html-webkit.c
@@ -377,6 +377,7 @@ handle_embedded_object( GncHtmlWebkit* self, gchar* html_str )
     if ( end_object_tag == NULL )
     {
         //  Hmmm... no object end tag
+        g_free (object_classid);
         return html_str;
     }
     end_object_tag += strlen( "</object>" );
-- 
1.7.5.4

>From 3ce82667bf6edd1bccb81250daf4843cdb2d2d1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aurimas=20Fi=C5=A1eras?= <[email protected]>
Date: Sat, 27 Aug 2011 12:47:05 +0300
Subject: (cppcheck) Fix mismatching allocation and deallocation

---
 src/gnome-utils/gnc-tree-model-account.c |    4 ++--
 src/gnome-utils/gnc-tree-model-owner.c   |    2 +-
 src/gnome-utils/gnc-tree-view.c          |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gnome-utils/gnc-tree-model-account.c b/src/gnome-utils/gnc-tree-model-account.c
index ec74438..0a80701 100644
--- a/src/gnome-utils/gnc-tree-model-account.c
+++ b/src/gnome-utils/gnc-tree-model-account.c
@@ -998,7 +998,7 @@ gnc_tree_model_account_iter_nth_child (GtkTreeModel *tree_model,
     if (parent_iter)
     {
         gchar *parent_string;
-        parent_string = strdup(iter_to_string(parent_iter));
+        parent_string = g_strdup(iter_to_string(parent_iter));
         ENTER("model %p, iter %s, parent_iter %s, n %d",
               tree_model, iter_to_string(iter),
               parent_string, n);
@@ -1065,7 +1065,7 @@ gnc_tree_model_account_iter_parent (GtkTreeModel *tree_model,
     {
         gchar *child_string;
 
-        child_string = strdup(iter_to_string(child));
+        child_string = g_strdup(iter_to_string(child));
         ENTER("model %p, iter %s, child %s",
               tree_model, iter_to_string(iter),
               child_string);
diff --git a/src/gnome-utils/gnc-tree-model-owner.c b/src/gnome-utils/gnc-tree-model-owner.c
index e496c09..db925e0 100644
--- a/src/gnome-utils/gnc-tree-model-owner.c
+++ b/src/gnome-utils/gnc-tree-model-owner.c
@@ -799,7 +799,7 @@ gnc_tree_model_owner_iter_nth_child (GtkTreeModel *tree_model,
     if (parent_iter)
     {
         gchar *parent_string;
-        parent_string = strdup(iter_to_string(parent_iter));
+        parent_string = g_strdup(iter_to_string(parent_iter));
         ENTER("model %p, iter %s, parent_iter %s, n %d",
               tree_model, iter_to_string(iter),
               parent_string, n);
diff --git a/src/gnome-utils/gnc-tree-view.c b/src/gnome-utils/gnc-tree-view.c
index b50fdf9..5fad2cf 100644
--- a/src/gnome-utils/gnc-tree-view.c
+++ b/src/gnome-utils/gnc-tree-view.c
@@ -1102,7 +1102,7 @@ gnc_tree_view_gconf_changed (GConfClient *client,
         /* Make a copy of the local part of the key so it can be split
          * into column name and key type */
         known = FALSE;
-        column_name = strdup(local);
+        column_name = g_strdup(local);
         type_name = strrchr(column_name, '_');
         *type_name++ = '\0';
 
-- 
1.7.5.4

>From 7eed760a8e113b540225c6d77645f1159696fa08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aurimas=20Fi=C5=A1eras?= <[email protected]>
Date: Sat, 27 Aug 2011 12:43:17 +0300
Subject: (cppcheck) Fix a possible memory leak: data

---
 src/gnome-utils/gnc-main-window.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c
index e920552..3f673b3 100644
--- a/src/gnome-utils/gnc-main-window.c
+++ b/src/gnome-utils/gnc-main-window.c
@@ -2821,14 +2821,14 @@ gnc_main_window_merge_actions (GncMainWindow *window,
     g_return_if_fail (n_actions > 0);
     g_return_if_fail (filename != NULL);
 
-    data = g_new0 (GncMainWindowActionData, 1);
-    data->window = window;
-    data->data = user_data;
-
     pathname = gnc_gnome_locate_ui_file (filename);
     if (pathname == NULL)
         return;
 
+    data = g_new0 (GncMainWindowActionData, 1);
+    data->window = window;
+    data->data = user_data;
+
     priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
     entry = g_new0 (MergedActionEntry, 1);
     entry->action_group = gtk_action_group_new (group_name);
-- 
1.7.5.4

>From 06fee33a11d44cd079fca0cacbb96e6aeab99fe8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aurimas=20Fi=C5=A1eras?= <[email protected]>
Date: Sat, 27 Aug 2011 12:26:27 +0300
Subject: (cppcheck) Fix mismatching allocation and deallocation: namespace

---
 src/gnome-utils/dialog-commodity.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gnome-utils/dialog-commodity.c b/src/gnome-utils/dialog-commodity.c
index 6083b96..1d6cdfa 100644
--- a/src/gnome-utils/dialog-commodity.c
+++ b/src/gnome-utils/dialog-commodity.c
@@ -730,7 +730,7 @@ gnc_ui_update_namespace_picker (GtkWidget *cbe,
 gchar *
 gnc_ui_namespace_picker_ns (GtkWidget *cbe)
 {
-    char *namespace;
+    gchar *namespace;
 
     g_return_val_if_fail(GTK_IS_COMBO_BOX_ENTRY (cbe), NULL);
 
@@ -740,7 +740,7 @@ gnc_ui_namespace_picker_ns (GtkWidget *cbe)
     {
         /* In case the user types in ISO4217, map it to CURRENCY. */
         g_free(namespace);
-        return strdup(GNC_COMMODITY_NS_CURRENCY);
+        return g_strdup(GNC_COMMODITY_NS_CURRENCY);
     }
     else
         return namespace;
-- 
1.7.5.4

>From 77bd3d397b6299eac852f13a7e7722574d0ed283 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aurimas=20Fi=C5=A1eras?= <[email protected]>
Date: Sat, 27 Aug 2011 12:21:32 +0300
Subject: (cppcheck) Remove several redundant null checks

---
 src/engine/Split.c      |   12 ++++++------
 src/engine/gncInvoice.c |    4 ++--
 src/engine/gncOrder.c   |    4 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/engine/Split.c b/src/engine/Split.c
index 8840870..688909f 100644
--- a/src/engine/Split.c
+++ b/src/engine/Split.c
@@ -1374,8 +1374,8 @@ xaccSplitOrder (const Split *sa, const Split *sb)
 
     if (sa == sb) return 0;
     /* nothing is always less than something */
-    if (!sa && sb) return -1;
-    if (sa && !sb) return +1;
+    if (!sa) return -1;
+    if (!sb) return +1;
 
     retval = xaccTransOrder (sa->parent, sb->parent);
     if (retval) return retval;
@@ -1424,14 +1424,14 @@ xaccSplitOrderDateOnly (const Split *sa, const Split *sb)
 
     if (sa == sb) return 0;
     /* nothing is always less than something */
-    if (!sa && sb) return -1;
-    if (sa && !sb) return +1;
+    if (!sa) return -1;
+    if (!sb) return +1;
 
     ta = sa->parent;
     tb = sb->parent;
-    if ( ta && !tb ) return -1;
-    if ( !ta && tb ) return +1;
     if ( !ta && !tb ) return 0;
+    if ( !tb ) return -1;
+    if ( !ta ) return +1;
 
     /* if dates differ, return */
     DATE_CMP(ta, tb, date_posted);
diff --git a/src/engine/gncInvoice.c b/src/engine/gncInvoice.c
index c69c9a0..b8761f4 100644
--- a/src/engine/gncInvoice.c
+++ b/src/engine/gncInvoice.c
@@ -1629,8 +1629,8 @@ int gncInvoiceCompare (const GncInvoice *a, const GncInvoice *b)
     int compare;
 
     if (a == b) return 0;
-    if (!a && b) return -1;
-    if (a && !b) return 1;
+    if (!a) return -1;
+    if (!b) return 1;
 
     compare = safe_strcmp (a->id, b->id);
     if (compare) return compare;
diff --git a/src/engine/gncOrder.c b/src/engine/gncOrder.c
index 6162eb1..75e4223 100644
--- a/src/engine/gncOrder.c
+++ b/src/engine/gncOrder.c
@@ -430,8 +430,8 @@ int gncOrderCompare (const GncOrder *a, const GncOrder *b)
     int compare;
 
     if (a == b) return 0;
-    if (!a && b) return -1;
-    if (a && !b) return 1;
+    if (!a) return -1;
+    if (!b) return 1;
 
     compare = safe_strcmp (a->id, b->id);
     if (compare) return compare;
-- 
1.7.5.4

_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to