gnucash maint: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Fri Nov 30 02:12:02 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/3f09e5c6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e81bcf6e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bf55c30a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a9344841 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f5260996 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/185787d7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8ed9a9c4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7e10b05c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7283c86f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/876bfd19 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/24ce9205 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8f22c4be (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4ffeb3ef (commit)
	 via  https://github.com/Gnucash/gnucash/commit/43a30e1c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3d136275 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/606d9cfe (commit)
	 via  https://github.com/Gnucash/gnucash/commit/faba7975 (commit)
	from  https://github.com/Gnucash/gnucash/commit/de6c173e (commit)



commit 3f09e5c6f1af66223503eca9adee84e9a346e42a
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Nov 30 16:11:42 2018 +0900

    Only disable register warnings for SWIG 2.
    
    SWIG 3 has removed the register storage class markers.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b127e44..d030943 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -288,6 +288,7 @@ endif (WIN32)
 if(GENERATE_SWIG_WRAPPERS)
   find_package (SWIG 2.0.10 REQUIRED)
   include (${SWIG_USE_FILE})
+  string(REGEX MATCH "^[0-9]+\." SWIG_MAJOR ${SWIG_VERSION})
 endif()
 
 # Find Guile and determine which version we are using.
@@ -547,6 +548,8 @@ check_c_compiler_flag(-Wstringop-truncation have_stringop_truncation)
 if (have_stringop_truncation)
     set(HAVE_STRINGOP_TRUNCATION TRUE)
 endif()
+
+if (SWIG_MAJOR LESS 3)
 check_cxx_compiler_flag(-Wno-register have_no_register)
 if (have_no_register)
   set(REGISTER_CXXFLAG -Wno-register)
@@ -556,6 +559,7 @@ else()
     set(REGISTER_CXXFLAG -Wno-deprecated-register)
   endif()
 endif()
+endif()
 add_definitions(-D_GNU_SOURCE)
 
 if (APPLE)

commit e81bcf6e33bc5bcf2af8aca6931e537889e1a17a
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Nov 30 14:44:49 2018 +0900

    Fix the remaining static analysis warnings.
    
    Except two incorrect leak warnings and one about mktemp
     being insecure in the XML backend. See the respective
    comments about those.

diff --git a/gnucash/gnome-utils/gnc-tree-model-split-reg.c b/gnucash/gnome-utils/gnc-tree-model-split-reg.c
index 4688f5c..05ecd8a 100644
--- a/gnucash/gnome-utils/gnc-tree-model-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-model-split-reg.c
@@ -992,7 +992,7 @@ gnc_tree_model_split_reg_get_sub_account (GncTreeModelSplitReg *model)
 void
 gnc_tree_model_split_reg_update_query (GncTreeModelSplitReg *model, Query *query)
 {
-    GSList *p1 = NULL, *p2 = NULL, *p3 = NULL, *standard;
+    GSList *p1 = NULL, *p2 = NULL, *standard;
 
     time64 start;
     struct tm tm;
@@ -1019,7 +1019,7 @@ gnc_tree_model_split_reg_update_query (GncTreeModelSplitReg *model, Query *query
             else if (model->sort_depth == 3)
             {
                 p1 = g_slist_prepend (p1, SPLIT_RECONCILE);
-                p1 = g_slist_prepend (p2, SPLIT_DATE_RECONCILED);
+                p1 = g_slist_prepend (p1, SPLIT_DATE_RECONCILED);
                 p2 = standard;
             }
             break;
@@ -1061,7 +1061,7 @@ gnc_tree_model_split_reg_update_query (GncTreeModelSplitReg *model, Query *query
         case GNC_TREE_MODEL_SPLIT_REG_COL_RECN:
             {
                 p1 = g_slist_prepend (p1, SPLIT_RECONCILE);
-                p1 = g_slist_prepend (p2, SPLIT_DATE_RECONCILED);
+                p1 = g_slist_prepend (p1, SPLIT_DATE_RECONCILED);
                 p2 = standard;
             }
             break;
@@ -1088,7 +1088,7 @@ gnc_tree_model_split_reg_update_query (GncTreeModelSplitReg *model, Query *query
         xaccQueryAddDateMatchTT (query, TRUE, start, FALSE, 0, QOF_QUERY_AND);
     }
 
-    qof_query_set_sort_order (query, p1, p2, p3);
+    qof_query_set_sort_order (query, p1, p2, NULL);
 
 }
 
diff --git a/gnucash/gnome/dialog-commodities.c b/gnucash/gnome/dialog-commodities.c
index 7a5487e..b392c5b 100644
--- a/gnucash/gnome/dialog-commodities.c
+++ b/gnucash/gnome/dialog-commodities.c
@@ -222,7 +222,7 @@ add_clicked (CommoditiesDialog *cd)
     else
         name_space = NULL;
 
-    commodity = gnc_ui_new_commodity_modal (name_space, cd->dialog);
+    gnc_ui_new_commodity_modal (name_space, cd->dialog);
 }
 
 void
diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.c
index 101c030..9603c44 100644
--- a/gnucash/import-export/ofx/gnc-ofx-import.c
+++ b/gnucash/import-export/ofx/gnc-ofx-import.c
@@ -973,7 +973,7 @@ int ofx_proc_account_cb(struct OfxAccountData data, void * account_user_data)
          * calling 'gnc_import_select_account', allow the user to set book
          * options. */
         if (new_book)
-            new_book = gnc_new_book_option_display (GTK_WIDGET (gnc_ui_get_main_window (NULL)));
+            gnc_new_book_option_display (GTK_WIDGET (gnc_ui_get_main_window (NULL)));
 
         gnc_utf8_strip_invalid(data.account_name);
         gnc_utf8_strip_invalid(data.account_id);
diff --git a/libgnucash/backend/xml/gnc-xml-backend.cpp b/libgnucash/backend/xml/gnc-xml-backend.cpp
index 61a73ba..5242723 100644
--- a/libgnucash/backend/xml/gnc-xml-backend.cpp
+++ b/libgnucash/backend/xml/gnc-xml-backend.cpp
@@ -376,6 +376,11 @@ GncXmlBackend::write_to_file (bool make_backup)
     strcpy (tmp_name, m_fullpath.c_str());
     strcat (tmp_name, ".tmp-XXXXXX");
 
+    /* Clang static analyzer flags this as a security risk, which is
+     * theoretically true, but we can't use mkstemp because we need to
+     * open the file ourselves because of compression. None of the alternatives
+     * is any more secure.
+     */
     if (!mktemp (tmp_name))
     {
         g_free (tmp_name);
diff --git a/libgnucash/engine/gnc-pricedb.c b/libgnucash/engine/gnc-pricedb.c
index b7efb28..6e97e8e 100644
--- a/libgnucash/engine/gnc-pricedb.c
+++ b/libgnucash/engine/gnc-pricedb.c
@@ -2196,28 +2196,28 @@ gnc_pricedb_nth_price (GNCPriceDB *db,
                merged currency list. */
             GList **price_array = (GList **)g_new(gpointer, num_currencies);
             GList **next_list;
-            int i, j;
+            int i, j, k;
             GHashTableIter iter;
             gpointer key, value;
 
             /* Build an array of all the currencies this commodity has prices for */
             for (i = 0, g_hash_table_iter_init(&iter, currency_hash);
                  g_hash_table_iter_next(&iter, &key, &value) && i < num_currencies;
-                 i++)
+                 ++i)
             {
                 price_array[i] = value;
             }
 
-            /* Iterate n times to get the nth price, each time finding the currency
+            /* Iterate up to n times (there are i prices, so going past i will run off the end of the array) to get the nth price, each time finding the currency
                with the latest price */
-            for (i = 0; i <= n; i++)
+            for (k = 0; k < n && k < i; ++k)
             {
                 next_list = NULL;
-                for (j = 0; j < num_currencies; j++)
+                for (j = 0; j < i; ++j)
                 {
                     /* Save this entry if it's the first one or later than
                        the saved one. */
-                    if (price_array[j] != NULL &&
+                    if (price_array[k] != NULL &&
                         (next_list == NULL || *next_list == NULL ||
                         compare_prices_by_date((*next_list)->data, (price_array[j])->data) > 0))
                     {
diff --git a/libgnucash/engine/gncEntry.c b/libgnucash/engine/gncEntry.c
index 654e7ec..dc6ad8b 100644
--- a/libgnucash/engine/gncEntry.c
+++ b/libgnucash/engine/gncEntry.c
@@ -1599,7 +1599,7 @@ int gncEntryCompare (const GncEntry *a, const GncEntry *b)
     if (a == b) return 0;
     if (!a && b) return -1;
     if (a && !b) return 1;
-
+    g_assert (a && b);  /* Silence a static analysis warning. */
     if (a->date != b->date) return a->date - b->date;
     if (a->date_entered != b->date_entered) return a->date_entered - b->date_entered;
 
diff --git a/libgnucash/engine/gncTaxTable.c b/libgnucash/engine/gncTaxTable.c
index 9175216..6159d12 100644
--- a/libgnucash/engine/gncTaxTable.c
+++ b/libgnucash/engine/gncTaxTable.c
@@ -722,6 +722,8 @@ static GncTaxTable *gncTaxTableCopy (const GncTaxTable *table)
         GncTaxTableEntry *entry, *e;
         entry = list->data;
         e = gncTaxTableEntryCopy (entry);
+       /* Clang static analyzer thinks we're leaking e, but we're not.
+        * We're transferring it to table. */
         gncTaxTableAddEntry (t, e);
     }
     return t;
diff --git a/libgnucash/engine/kvp-value.cpp b/libgnucash/engine/kvp-value.cpp
index 5c4addd..bbfedf6 100644
--- a/libgnucash/engine/kvp-value.cpp
+++ b/libgnucash/engine/kvp-value.cpp
@@ -344,6 +344,7 @@ compare(const KvpValueImpl * one, const KvpValueImpl * two) noexcept
     if (one == two) return 0;
     if (one && !two) return 1;
     if (!one && two) return -1;
+    assert (one && two);  /* Silence a static analysis warning. */
     return compare(*one, *two);
 }
 

commit bf55c30aeb2a94a6bd29015278d8aa84e498011e
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Nov 30 13:56:08 2018 +0900

    Fix most of the unused assignment errors from static analysis.
    
    There are a very few left that need deeper study, but this gets
    rid of most of the noise. For the most part it's just getting rid of
    extra variables or removing an assignment that is always
    replaced later but before any reads of the variable. A few are
    discarded result variables.

diff --git a/borrowed/gwengui-gtk3/gtk3_gui_dialog.c b/borrowed/gwengui-gtk3/gtk3_gui_dialog.c
index d047b5f..13a0b95 100644
--- a/borrowed/gwengui-gtk3/gtk3_gui_dialog.c
+++ b/borrowed/gwengui-gtk3/gtk3_gui_dialog.c
@@ -528,12 +528,10 @@ int Gtk3Gui_GetRawText(const char *text, GWEN_BUFFER *tbuf) {
 
   if (p && p2) {
     int startPos;
-    int endPos;
 
     p2+=7; /* skip "</html>" */
 
     startPos=(p-text);
-    endPos=(p2-text);
 
     /* append stuff before startPos */
     if (startPos)
diff --git a/borrowed/gwengui-gtk3/w_checkbox.c b/borrowed/gwengui-gtk3/w_checkbox.c
index f8d8661..f79c8e0 100644
--- a/borrowed/gwengui-gtk3/w_checkbox.c
+++ b/borrowed/gwengui-gtk3/w_checkbox.c
@@ -162,11 +162,8 @@ static void Gtk3Gui_WCheckBox_Toggled_handler(GtkButton *button, gpointer data)
 static int Gtk3Gui_WCheckBox_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
   const char *s;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
-  gulong toggled_handler_id;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
   s=GWEN_Widget_GetText(w, 0);
 
@@ -184,10 +181,10 @@ static int Gtk3Gui_WCheckBox_Setup(GWEN_WIDGET *w) {
   GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WCheckBox_SetCharProperty);
   GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WCheckBox_GetCharProperty);
 
-  toggled_handler_id=g_signal_connect(g,
-                                      "toggled",
-                                      G_CALLBACK (Gtk3Gui_WCheckBox_Toggled_handler),
-                                      w);
+  g_signal_connect(g,
+                   "toggled",
+                   G_CALLBACK (Gtk3Gui_WCheckBox_Toggled_handler),
+                   w);
 
   if (wParent)
     GWEN_Widget_AddChildGuiWidget(wParent, w);
diff --git a/borrowed/gwengui-gtk3/w_combobox.c b/borrowed/gwengui-gtk3/w_combobox.c
index 50dc1dc..2483442 100644
--- a/borrowed/gwengui-gtk3/w_combobox.c
+++ b/borrowed/gwengui-gtk3/w_combobox.c
@@ -250,7 +250,6 @@ int Gtk3Gui_WComboBox_Setup(GWEN_WIDGET *w) {
   GtkListStore *store;
   uint32_t flags;
   GWEN_WIDGET *wParent;
-  gulong changed_handler_id;
 
   flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
@@ -283,10 +282,10 @@ int Gtk3Gui_WComboBox_Setup(GWEN_WIDGET *w) {
   GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WComboBox_SetCharProperty);
   GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WComboBox_GetCharProperty);
 
-  changed_handler_id=g_signal_connect(g,
-                                      "changed",
-                                      G_CALLBACK (changed_handler),
-                                      w);
+  g_signal_connect(g,
+                   "changed",
+                   G_CALLBACK (changed_handler),
+                   w);
 
   if (wParent)
     GWEN_Widget_AddChildGuiWidget(wParent, w);
diff --git a/borrowed/gwengui-gtk3/w_dialog.c b/borrowed/gwengui-gtk3/w_dialog.c
index 42dfa4d..46a8265 100644
--- a/borrowed/gwengui-gtk3/w_dialog.c
+++ b/borrowed/gwengui-gtk3/w_dialog.c
@@ -177,9 +177,7 @@ int Gtk3Gui_WDialog_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
 static int Gtk3Gui_WDialog_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
   const char *s;
-  uint32_t flags;
 
-  flags=GWEN_Widget_GetFlags(w);
   s=GWEN_Widget_GetText(w, 0);
 
   g=gtk_window_new(GTK_WINDOW_TOPLEVEL);
diff --git a/borrowed/gwengui-gtk3/w_gridlayout.c b/borrowed/gwengui-gtk3/w_gridlayout.c
index 622cba4..f348db9 100644
--- a/borrowed/gwengui-gtk3/w_gridlayout.c
+++ b/borrowed/gwengui-gtk3/w_gridlayout.c
@@ -128,7 +128,6 @@ int Gtk3Gui_WGridLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
   GTK3_GRIDLAYOUT_WIDGET *xw;
   GtkWidget *g;
   GtkWidget *gChild;
-  uint32_t cflags;
   int x;
   int y;
 
@@ -136,7 +135,6 @@ int Gtk3Gui_WGridLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
   xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, GTK3_GRIDLAYOUT_WIDGET, w);
   assert(xw);
 
-  cflags=GWEN_Widget_GetFlags(wChild);
 
   g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
   assert(g);
@@ -194,7 +192,6 @@ void Gtk3Gui_WGridLayout_FreeData(void *bp, void *p) {
 
 static int Gtk3Gui_WGridLayout_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
   GTK3_GRIDLAYOUT_WIDGET *xw;
   int rows;
@@ -203,7 +200,6 @@ static int Gtk3Gui_WGridLayout_Setup(GWEN_WIDGET *w) {
   GWEN_NEW_OBJECT(GTK3_GRIDLAYOUT_WIDGET, xw);
   GWEN_INHERIT_SETDATA(GWEN_WIDGET, GTK3_GRIDLAYOUT_WIDGET, w, xw, Gtk3Gui_WGridLayout_FreeData);
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
   cols=GWEN_Widget_GetColumns(w);
   rows=GWEN_Widget_GetRows(w);
diff --git a/borrowed/gwengui-gtk3/w_groupbox.c b/borrowed/gwengui-gtk3/w_groupbox.c
index be41b5d..b990620 100644
--- a/borrowed/gwengui-gtk3/w_groupbox.c
+++ b/borrowed/gwengui-gtk3/w_groupbox.c
@@ -171,10 +171,8 @@ static int Gtk3Gui_WGroupBox_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
   GtkWidget *gContent;
   const char *s;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
   s=GWEN_Widget_GetText(w, 0);
 
diff --git a/borrowed/gwengui-gtk3/w_hlayout.c b/borrowed/gwengui-gtk3/w_hlayout.c
index 792e9f4..aea03e3 100644
--- a/borrowed/gwengui-gtk3/w_hlayout.c
+++ b/borrowed/gwengui-gtk3/w_hlayout.c
@@ -137,10 +137,8 @@ int Gtk3Gui_WHLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
 
 static int Gtk3Gui_WHLayout_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   g=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,
diff --git a/borrowed/gwengui-gtk3/w_hline.c b/borrowed/gwengui-gtk3/w_hline.c
index b074a52..2996254 100644
--- a/borrowed/gwengui-gtk3/w_hline.c
+++ b/borrowed/gwengui-gtk3/w_hline.c
@@ -76,10 +76,8 @@ int Gtk3Gui_WHLine_GetIntProperty(GWEN_WIDGET *w,
 
 static int Gtk3Gui_WHLine_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   g=gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
diff --git a/borrowed/gwengui-gtk3/w_hspacer.c b/borrowed/gwengui-gtk3/w_hspacer.c
index 22790c7..6bd17b2 100644
--- a/borrowed/gwengui-gtk3/w_hspacer.c
+++ b/borrowed/gwengui-gtk3/w_hspacer.c
@@ -76,10 +76,8 @@ int Gtk3Gui_WHSpacer_GetIntProperty(GWEN_WIDGET *w,
 
 static int Gtk3Gui_WHSpacer_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   g=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
diff --git a/borrowed/gwengui-gtk3/w_label.c b/borrowed/gwengui-gtk3/w_label.c
index 210e6fd..0c0122b 100644
--- a/borrowed/gwengui-gtk3/w_label.c
+++ b/borrowed/gwengui-gtk3/w_label.c
@@ -146,11 +146,9 @@ const char* Gtk3Gui_WLabel_GetCharProperty(GWEN_WIDGET *w,
 static int Gtk3Gui_WLabel_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
   const char *s;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
   GWEN_BUFFER *tbuf;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
   s=GWEN_Widget_GetText(w, 0);
 
diff --git a/borrowed/gwengui-gtk3/w_lineedit.c b/borrowed/gwengui-gtk3/w_lineedit.c
index 90aa126..25f8d81 100644
--- a/borrowed/gwengui-gtk3/w_lineedit.c
+++ b/borrowed/gwengui-gtk3/w_lineedit.c
@@ -183,8 +183,6 @@ static int Gtk3Gui_WLineEdit_Setup(GWEN_WIDGET *w) {
   const char *s;
   uint32_t flags;
   GWEN_WIDGET *wParent;
-  gulong deleted_text_handler_id;
-  gulong inserted_text_handler_id;
   gboolean text_is_visible;
 
   flags=GWEN_Widget_GetFlags(w);
@@ -206,15 +204,15 @@ static int Gtk3Gui_WLineEdit_Setup(GWEN_WIDGET *w) {
   GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WLineEdit_SetCharProperty);
   GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WLineEdit_GetCharProperty);
 
-  deleted_text_handler_id=g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
-                          "deleted-text",
-                          G_CALLBACK (Gtk3Gui_WLineEdit_Deleted_text_handler),
-                          w);
+  g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
+                   "deleted-text",
+                   G_CALLBACK (Gtk3Gui_WLineEdit_Deleted_text_handler),
+                   w);
 
-  inserted_text_handler_id=g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
-                           "inserted-text",
-                           G_CALLBACK (Gtk3Gui_WLineEdit_Inserted_text_handler),
-                           w);
+  g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
+                   "inserted-text",
+                   G_CALLBACK (Gtk3Gui_WLineEdit_Inserted_text_handler),
+                   w);
 
   if (wParent)
     GWEN_Widget_AddChildGuiWidget(wParent, w);
diff --git a/borrowed/gwengui-gtk3/w_listbox.c b/borrowed/gwengui-gtk3/w_listbox.c
index e4c44cf..ec71e2f 100644
--- a/borrowed/gwengui-gtk3/w_listbox.c
+++ b/borrowed/gwengui-gtk3/w_listbox.c
@@ -252,7 +252,6 @@ int Gtk3Gui_WListBox_SetCharProperty(GWEN_WIDGET *w,
       GType types[W_LISTBOX_MAX_TYPES];
       GtkListStore *sto;
       int i;
-      const char *s;
       GtkTreeViewColumn *col;
       char *vcopy;
       char *p;
@@ -262,7 +261,6 @@ int Gtk3Gui_WListBox_SetCharProperty(GWEN_WIDGET *w,
       for (i=0; i<cols; i++)
         types[i]=G_TYPE_STRING;
       sto=gtk_list_store_newv(cols, types);
-      s=value;
 
       /* clear current headers in tree view */
       while( (col=gtk_tree_view_get_column(GTK_TREE_VIEW(g), 0)) )
@@ -497,11 +495,8 @@ static void Gtk3Gui_WListBox_CursorChanged_handler(GtkTreeView *g, gpointer data
 static int Gtk3Gui_WListBox_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
   GtkWidget *gScroll;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
-  gulong changed_handler_id;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   gScroll=gtk_scrolled_window_new(NULL, NULL);
@@ -526,10 +521,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WListBox_SetCharProperty);
   GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WListBox_GetCharProperty);
 
-  changed_handler_id=g_signal_connect(g,
-                                      "cursor-changed",
-                                      G_CALLBACK (Gtk3Gui_WListBox_CursorChanged_handler),
-                                      w);
+  g_signal_connect(g,
+                   "cursor-changed",
+                   G_CALLBACK (Gtk3Gui_WListBox_CursorChanged_handler),
+                   w);
 
   if (wParent)
     GWEN_Widget_AddChildGuiWidget(wParent, w);
diff --git a/borrowed/gwengui-gtk3/w_progressbar.c b/borrowed/gwengui-gtk3/w_progressbar.c
index 6a159f6..7bd4cda 100644
--- a/borrowed/gwengui-gtk3/w_progressbar.c
+++ b/borrowed/gwengui-gtk3/w_progressbar.c
@@ -209,17 +209,13 @@ static void GWENHYWFAR_CB Gtk3Gui_WProgressBar_FreeData(void *bp, void *p) {
 
 static int Gtk3Gui_WProgressBar_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  const char *s;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
   W_PROGRESSBAR *xw;
 
   GWEN_NEW_OBJECT(W_PROGRESSBAR, xw);
   GWEN_INHERIT_SETDATA(GWEN_WIDGET, W_PROGRESSBAR, w, xw, Gtk3Gui_WProgressBar_FreeData);
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
-  s=GWEN_Widget_GetText(w, 0);
 
   g=gtk_progress_bar_new();
   GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
diff --git a/borrowed/gwengui-gtk3/w_pushbutton.c b/borrowed/gwengui-gtk3/w_pushbutton.c
index 35d7554..aac9440 100644
--- a/borrowed/gwengui-gtk3/w_pushbutton.c
+++ b/borrowed/gwengui-gtk3/w_pushbutton.c
@@ -156,11 +156,8 @@ static void Gtk3Gui_WPushButton_Clicked_handler(GtkButton *button, gpointer data
 static int Gtk3Gui_WPushButton_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
   const char *s;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
-  gulong clicked_handler_id;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
   s=GWEN_Widget_GetText(w, 0);
 
@@ -204,10 +201,10 @@ static int Gtk3Gui_WPushButton_Setup(GWEN_WIDGET *w) {
   GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WPushButton_SetCharProperty);
   GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WPushButton_GetCharProperty);
 
-  clicked_handler_id=g_signal_connect(g,
-                                      "clicked",
-                                      G_CALLBACK (Gtk3Gui_WPushButton_Clicked_handler),
-                                      w);
+  g_signal_connect(g,
+                   "clicked",
+                   G_CALLBACK (Gtk3Gui_WPushButton_Clicked_handler),
+                   w);
 
   if (wParent)
     GWEN_Widget_AddChildGuiWidget(wParent, w);
diff --git a/borrowed/gwengui-gtk3/w_radiobutton.c b/borrowed/gwengui-gtk3/w_radiobutton.c
index 9efe271..9e9d942 100644
--- a/borrowed/gwengui-gtk3/w_radiobutton.c
+++ b/borrowed/gwengui-gtk3/w_radiobutton.c
@@ -162,13 +162,11 @@ static void Gtk3Gui_WRadioButton_Toggled_handler(GtkButton *button, gpointer dat
 static int Gtk3Gui_WRadioButton_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
   const char *s;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
   GWEN_WIDGET *wT;
   gulong toggled_handler_id;
   int groupId;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
   groupId=GWEN_Widget_GetGroupId(w);
 
@@ -208,10 +206,10 @@ static int Gtk3Gui_WRadioButton_Setup(GWEN_WIDGET *w) {
   GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WRadioButton_SetCharProperty);
   GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WRadioButton_GetCharProperty);
 
-  toggled_handler_id=g_signal_connect(g,
-                                      "toggled",
-                                      G_CALLBACK (Gtk3Gui_WRadioButton_Toggled_handler),
-                                      w);
+  g_signal_connect(g,
+                   "toggled",
+                   G_CALLBACK (Gtk3Gui_WRadioButton_Toggled_handler),
+                   w);
 
   if (wParent)
     GWEN_Widget_AddChildGuiWidget(wParent, w);
diff --git a/borrowed/gwengui-gtk3/w_scrollarea.c b/borrowed/gwengui-gtk3/w_scrollarea.c
index 8e36791..4671ba5 100644
--- a/borrowed/gwengui-gtk3/w_scrollarea.c
+++ b/borrowed/gwengui-gtk3/w_scrollarea.c
@@ -163,10 +163,8 @@ int Gtk3Gui_WScrollArea_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
 static int Gtk3Gui_WScrollArea_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
   GtkWidget *gContent;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   /* create widget */
diff --git a/borrowed/gwengui-gtk3/w_spinbox.c b/borrowed/gwengui-gtk3/w_spinbox.c
index f0630ed..fb530d2 100644
--- a/borrowed/gwengui-gtk3/w_spinbox.c
+++ b/borrowed/gwengui-gtk3/w_spinbox.c
@@ -178,18 +178,13 @@ static void Gtk3Gui_WSpinBox_Changed_handler(GtkAdjustment *adjustment, gpointer
 
 static int Gtk3Gui_WSpinBox_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  const char *s;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
   W_SPINBOX *xw;
-  gulong changed_handler_id;
 
   GWEN_NEW_OBJECT(W_SPINBOX, xw);
   GWEN_INHERIT_SETDATA(GWEN_WIDGET, W_SPINBOX, w, xw, Gtk3Gui_WSpinBox_FreeData);
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
-  s=GWEN_Widget_GetText(w, 0);
 
   xw->adjustment=GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 5.0, 5.0));
   g=gtk_spin_button_new(xw->adjustment, 1.0, 0);
@@ -201,10 +196,10 @@ static int Gtk3Gui_WSpinBox_Setup(GWEN_WIDGET *w) {
   GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WSpinBox_SetCharProperty);
   GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WSpinBox_GetCharProperty);
 
-  changed_handler_id=g_signal_connect(g,
-                                      "value-changed",
-                                      G_CALLBACK (Gtk3Gui_WSpinBox_Changed_handler),
-                                      w);
+  g_signal_connect(g,
+                   "value-changed",
+                   G_CALLBACK (Gtk3Gui_WSpinBox_Changed_handler),
+                   w);
 
   if (wParent)
     GWEN_Widget_AddChildGuiWidget(wParent, w);
diff --git a/borrowed/gwengui-gtk3/w_stack.c b/borrowed/gwengui-gtk3/w_stack.c
index d015f65..7a37eee 100644
--- a/borrowed/gwengui-gtk3/w_stack.c
+++ b/borrowed/gwengui-gtk3/w_stack.c
@@ -147,10 +147,8 @@ int Gtk3Gui_WStack_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
 
 static int Gtk3Gui_WStack_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   g=gtk_notebook_new();
diff --git a/borrowed/gwengui-gtk3/w_tabbook.c b/borrowed/gwengui-gtk3/w_tabbook.c
index 476f5ae..31077ad 100644
--- a/borrowed/gwengui-gtk3/w_tabbook.c
+++ b/borrowed/gwengui-gtk3/w_tabbook.c
@@ -141,10 +141,8 @@ int Gtk3Gui_WTabBook_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
 
 static int Gtk3Gui_WTabBook_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   g=gtk_notebook_new();
diff --git a/borrowed/gwengui-gtk3/w_textbrowser.c b/borrowed/gwengui-gtk3/w_textbrowser.c
index bd722d0..a634726 100644
--- a/borrowed/gwengui-gtk3/w_textbrowser.c
+++ b/borrowed/gwengui-gtk3/w_textbrowser.c
@@ -193,10 +193,8 @@ static int Gtk3Gui_WTextBrowser_Setup(GWEN_WIDGET *w) {
   GtkWidget *gs;
   GtkWidget *g;
   const char *s;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
   s=GWEN_Widget_GetText(w, 0);
 
diff --git a/borrowed/gwengui-gtk3/w_textedit.c b/borrowed/gwengui-gtk3/w_textedit.c
index c470586..60201a9 100644
--- a/borrowed/gwengui-gtk3/w_textedit.c
+++ b/borrowed/gwengui-gtk3/w_textedit.c
@@ -187,11 +187,8 @@ static void Gtk3Gui_WTextEdit_Changed_handler(GtkTextBuffer *buffer, gpointer da
 static int Gtk3Gui_WTextEdit_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
   const char *s;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
-  gulong changed_handler_id;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
   s=GWEN_Widget_GetText(w, 0);
 
@@ -208,7 +205,7 @@ static int Gtk3Gui_WTextEdit_Setup(GWEN_WIDGET *w) {
   GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WTextEdit_SetCharProperty);
   GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WTextEdit_GetCharProperty);
 
-  changed_handler_id=g_signal_connect(gtk_text_view_get_buffer(GTK_TEXT_VIEW(g)),
+  g_signal_connect(gtk_text_view_get_buffer(GTK_TEXT_VIEW(g)),
                                       "changed",
                                       G_CALLBACK (Gtk3Gui_WTextEdit_Changed_handler),
                                       w);
diff --git a/borrowed/gwengui-gtk3/w_vlayout.c b/borrowed/gwengui-gtk3/w_vlayout.c
index e7431aa..d685111 100644
--- a/borrowed/gwengui-gtk3/w_vlayout.c
+++ b/borrowed/gwengui-gtk3/w_vlayout.c
@@ -137,10 +137,8 @@ int Gtk3Gui_WVLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
 
 static int Gtk3Gui_WVLayout_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   g=gtk_box_new(GTK_ORIENTATION_VERTICAL,
diff --git a/borrowed/gwengui-gtk3/w_vline.c b/borrowed/gwengui-gtk3/w_vline.c
index 256bfcf..75989a1 100644
--- a/borrowed/gwengui-gtk3/w_vline.c
+++ b/borrowed/gwengui-gtk3/w_vline.c
@@ -76,10 +76,8 @@ int Gtk3Gui_WVLine_GetIntProperty(GWEN_WIDGET *w,
 
 static int Gtk3Gui_WVLine_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   g=gtk_separator_new(GTK_ORIENTATION_VERTICAL);
diff --git a/borrowed/gwengui-gtk3/w_vspacer.c b/borrowed/gwengui-gtk3/w_vspacer.c
index faa7c7d..c055931 100644
--- a/borrowed/gwengui-gtk3/w_vspacer.c
+++ b/borrowed/gwengui-gtk3/w_vspacer.c
@@ -76,10 +76,8 @@ int Gtk3Gui_WVSpacer_GetIntProperty(GWEN_WIDGET *w,
 
 static int Gtk3Gui_WVSpacer_Setup(GWEN_WIDGET *w) {
   GtkWidget *g;
-  uint32_t flags;
   GWEN_WIDGET *wParent;
 
-  flags=GWEN_Widget_GetFlags(w);
   wParent=GWEN_Widget_Tree_GetParent(w);
 
   g=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
diff --git a/borrowed/jenny/jenny.c b/borrowed/jenny/jenny.c
index d82b10c..ddda20d 100644
--- a/borrowed/jenny/jenny.c
+++ b/borrowed/jenny/jenny.c
@@ -1184,7 +1184,7 @@ build_tuples( state *s, ub2 d, ub2 f)
 {
   feature  offset[MAX_N];                                      /* n-1-tuples */
   feature  tuple[MAX_N];                      /* n-tuples that include (d,f) */
-  sb4      i, j, n = s->n[d][f];
+  sb4      i, j, n;
   ub8      count = 0;
   test    *t;
   tu_iter  ctx;
@@ -1522,7 +1522,6 @@ cover_tuples( state *s)
     ub4         tuple_count = 0;
     ub1         covered = FALSE;
     feature    *tuple = (feature *)0;
-    ub4         tuple_f, tuple_d;
 
     /* extend lists of tuples and choose one tuple to cover */
     for (d=0; d<s->ndim; ++d) {
@@ -1533,13 +1532,9 @@ cover_tuples( state *s)
           tuple_n = s->n[d][f];
           tuple_count = s->tc[d][f];
           tuple = s->tu[d][f]->fe;
-          tuple_f = f;
-          tuple_d = d;
         } else if (s->n[d][f] == tuple_n && s->tc[d][f] > tuple_count) {
           tuple_count = s->tc[d][f];
           tuple = s->tu[d][f]->fe;
-          tuple_f = f;
-          tuple_d = d;
         }
       }
     }
@@ -1748,9 +1743,7 @@ which_test( state *s)
 static void
 reduce_tests( state *s)
 {
-  ub4 t;
   prepare_reduce( s);
-  t = which_test( s);
 }
 
 /* Confirm that every tuple is covered by either a testcase or a without */
diff --git a/gnucash/gnome-utils/dialog-commodity.c b/gnucash/gnome-utils/dialog-commodity.c
index 3179b7a..97220e6 100644
--- a/gnucash/gnome-utils/dialog-commodity.c
+++ b/gnucash/gnome-utils/dialog-commodity.c
@@ -1352,7 +1352,7 @@ gnc_ui_commodity_dialog_to_object(CommodityWindow * w)
         gnc_commodity_commit_edit(c);
 
         /* remember the commodity */
-        c = gnc_commodity_table_insert(gnc_get_current_commodities(), c);
+        gnc_commodity_table_insert(gnc_get_current_commodities(), c);
     }
     else
     {
diff --git a/gnucash/gnome-utils/dialog-tax-table.c b/gnucash/gnome-utils/dialog-tax-table.c
index 9f9b8a8..67e6075 100644
--- a/gnucash/gnome-utils/dialog-tax-table.c
+++ b/gnucash/gnome-utils/dialog-tax-table.c
@@ -294,7 +294,7 @@ new_tax_table_dialog (TaxTableWindow *ttw, gboolean new_table,
         gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "spacer")));
         gtk_widget_hide (ntt->name_entry);
         /* Tables are great for layout, but a pain when you hide widgets */
-        widget = GTK_WIDGET(gtk_builder_get_object (builder, "ttd_table"));
+        GTK_WIDGET(gtk_builder_get_object (builder, "ttd_table"));
         gtk_widget_grab_focus (gnc_amount_edit_gtk_entry
                                (GNC_AMOUNT_EDIT (ntt->amount_entry)));
     }
diff --git a/gnucash/gnome-utils/dialog-transfer.c b/gnucash/gnome-utils/dialog-transfer.c
index 5971ddb..5add381 100644
--- a/gnucash/gnome-utils/dialog-transfer.c
+++ b/gnucash/gnome-utils/dialog-transfer.c
@@ -1299,8 +1299,7 @@ gnc_xfer_dialog_set_amount(XferDialog *xferData, gnc_numeric amount)
     account = gnc_transfer_dialog_get_selected_account (xferData,
                                                         XFER_DIALOG_FROM);
     if (account == NULL)
-        account = gnc_transfer_dialog_get_selected_account (xferData,
-                                                            XFER_DIALOG_TO);
+        gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_TO);
 
     gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (xferData->amount_edit), amount);
 }
diff --git a/gnucash/gnome-utils/gnc-cell-renderer-popup.c b/gnucash/gnome-utils/gnc-cell-renderer-popup.c
index d06991c..04bcf06 100644
--- a/gnucash/gnome-utils/gnc-cell-renderer-popup.c
+++ b/gnucash/gnome-utils/gnc-cell-renderer-popup.c
@@ -220,8 +220,8 @@ gcrp_grab_on_window (GdkWindow *window,
     GdkSeat *seat;
 #else
     GdkDeviceManager *device_manager;
-#endif
     GdkDevice *device;
+#endif
 
 #if GTK_CHECK_VERSION(3,22,0)
     GdkEvent *event = gtk_get_current_event ();
@@ -229,7 +229,6 @@ gcrp_grab_on_window (GdkWindow *window,
 
 #if GTK_CHECK_VERSION(3,20,0)
     seat = gdk_display_get_default_seat (display);
-    device = gdk_seat_get_pointer (seat);
 #else
     device_manager = gdk_display_get_device_manager (display);
     device = gdk_device_manager_get_client_pointer (device_manager);
@@ -316,7 +315,6 @@ gcrp_show_popup (GncCellRendererPopup *cell,
 		if (alloc.height > screen_height && y - button_height > screen_height) {
 			/* We don't, so we show the popup above the cell
 			   instead of below it. */
-			screen_height = y - button_height;
 			y -= (alloc.height + button_height);
 			if (y < 0) {
 				y = 0;
diff --git a/gnucash/gnome-utils/gnc-file.c b/gnucash/gnome-utils/gnc-file.c
index 7162cd8..0a0f774 100644
--- a/gnucash/gnome-utils/gnc-file.c
+++ b/gnucash/gnome-utils/gnc-file.c
@@ -86,7 +86,7 @@ gnc_file_dialog (GtkWindow *parent,
     GtkWidget *file_box;
     const char *internal_name;
     char *file_name = NULL;
-    gchar * okbutton = _("_Open");
+    gchar * okbutton;
     const gchar *ok_icon = NULL;
     GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
     gint response;
@@ -742,7 +742,6 @@ RESTART:
     {
         gchar *directory;
         show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_OPEN);
-        io_err = ERR_BACKEND_NO_ERR;
         if (g_file_test (filename, G_FILE_TEST_IS_DIR))
             directory = g_strdup (filename);
         else
diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index 1ba3b40..6e0d277 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -2965,7 +2965,6 @@ gnc_main_window_open_page (GncMainWindow *window,
     }
 
     page->window = GTK_WIDGET(window);
-    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
     page->notebook_page = gnc_plugin_page_create_widget (page);
     g_object_set_data (G_OBJECT (page->notebook_page),
                        PLUGIN_PAGE_LABEL, page);
@@ -4810,6 +4809,9 @@ do_popup_menu(GncPluginPage *page, GdkEventButton *event)
         return;
     }
 
+#if GTK_CHECK_VERSION(3,22,0)
+    gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event);
+#else
     if (event)
     {
         button = event->button;
@@ -4820,9 +4822,6 @@ do_popup_menu(GncPluginPage *page, GdkEventButton *event)
         button = 0;
         event_time = gtk_get_current_event_time ();
     }
-#if GTK_CHECK_VERSION(3,22,0)
-    gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event);
-#else
     gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, event_time);
 #endif
     LEAVE(" ");
diff --git a/gnucash/gnome-utils/gnc-period-select.c b/gnucash/gnome-utils/gnc-period-select.c
index c16d5d6..c5b514d 100644
--- a/gnucash/gnome-utils/gnc-period-select.c
+++ b/gnucash/gnome-utils/gnc-period-select.c
@@ -253,7 +253,6 @@ GDate *
 gnc_period_select_get_fy_end (GncPeriodSelect *period)
 {
     GncPeriodSelectPrivate *priv;
-    priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
 
     g_return_val_if_fail(period != NULL, NULL);
     g_return_val_if_fail(GNC_IS_PERIOD_SELECT(period), NULL);
diff --git a/gnucash/gnome-utils/gnc-tree-util-split-reg.c b/gnucash/gnome-utils/gnc-tree-util-split-reg.c
index 7f01c28..88240a3 100644
--- a/gnucash/gnome-utils/gnc-tree-util-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-util-split-reg.c
@@ -1082,7 +1082,6 @@ gnc_tree_util_set_number_for_input (GncTreeViewSplitReg *view, Transaction *tran
         if (gnc_numeric_zero_p (value))
         {
             amount = gnc_numeric_create (1,1);
-            value = gnc_numeric_mul (input, amount, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
             xaccSplitSetValue (split, input);
             xaccSplitSetAmount (split, amount);
             LEAVE("");
diff --git a/gnucash/gnome-utils/gnc-tree-view-commodity.c b/gnucash/gnome-utils/gnc-tree-view-commodity.c
index ebd2ea6..23a57d7 100644
--- a/gnucash/gnome-utils/gnc-tree-view-commodity.c
+++ b/gnucash/gnome-utils/gnc-tree-view-commodity.c
@@ -381,7 +381,7 @@ gnc_tree_view_commodity_new (QofBook *book,
     /* Set default visibilities */
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
 
-    col = gnc_tree_view_add_text_column (
+    gnc_tree_view_add_text_column (
               view, _("Namespace"), "namespace", NULL, "NASDAQ",
               GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE,
               GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
@@ -398,7 +398,7 @@ gnc_tree_view_commodity_new (QofBook *book,
               GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
               sort_by_commodity_string);
     g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
-    col = gnc_tree_view_add_text_column (
+    gnc_tree_view_add_text_column (
               view, _("Print Name"), "printname", NULL,
               "ACMEACME (Acme Corporation, Inc.)",
               GNC_TREE_MODEL_COMMODITY_COL_PRINTNAME,
@@ -410,7 +410,7 @@ gnc_tree_view_commodity_new (QofBook *book,
               GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
               sort_by_commodity_string);
     g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
-    col = gnc_tree_view_add_text_column (
+    gnc_tree_view_add_text_column (
               view, _("Unique Name"), "uniquename", NULL,
               "NASDAQ::ACMEACME", GNC_TREE_MODEL_COMMODITY_COL_UNIQUE_NAME,
               GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
@@ -430,7 +430,7 @@ gnc_tree_view_commodity_new (QofBook *book,
               GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
               sort_by_fraction);
     g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
-    col = gnc_tree_view_add_toggle_column(
+    gnc_tree_view_add_toggle_column(
               view, _("Get Quotes"),
               /* Translators: This string has a context prefix; the translation
                  must only contain the part after the | character. */
@@ -439,7 +439,7 @@ gnc_tree_view_commodity_new (QofBook *book,
               GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
               sort_by_quote_flag,
               NULL);
-    col = gnc_tree_view_add_text_column (
+    gnc_tree_view_add_text_column (
               view, _("Source"), "quote_source", NULL, "alphavantage",
               GNC_TREE_MODEL_COMMODITY_COL_QUOTE_SOURCE,
               GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
diff --git a/gnucash/gnome-utils/gnc-tree-view-price.c b/gnucash/gnome-utils/gnc-tree-view-price.c
index f4488fb..b098df1 100644
--- a/gnucash/gnome-utils/gnc-tree-view-price.c
+++ b/gnucash/gnome-utils/gnc-tree-view-price.c
@@ -420,7 +420,7 @@ gnc_tree_view_price_new (QofBook *book,
 
     sample_text = gnc_commodity_get_printname(gnc_default_currency());
     sample_text2 = g_strdup_printf("%s%s", sample_text, sample_text);
-    col = gnc_tree_view_add_text_column (
+    gnc_tree_view_add_text_column (
               view, _("Security"), "security", NULL, sample_text2,
               GNC_TREE_MODEL_PRICE_COL_COMMODITY,
               GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
diff --git a/gnucash/gnome-utils/gnc-tree-view-split-reg.c b/gnucash/gnome-utils/gnc-tree-view-split-reg.c
index 121a43b..bd89fb9 100644
--- a/gnucash/gnome-utils/gnc-tree-view-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-view-split-reg.c
@@ -1497,20 +1497,11 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
             editable = FALSE;
         }
         else if (is_split && show_extra_dates) {
-            time64 t = 0;
 
             if (xaccSplitGetReconcile (split) == YREC)
             {
-                t = xaccSplitGetDateReconciled (split);
-                //If the time returned by xaccTransGetDateEnteredTS is 0 then assume it
-                //is a new transaction and set the time to current time to show current
-                //date on new transactions
-                if (t == 0)
-                {
-                    t = gnc_time (NULL);
-                    //xaccSplitSetDateReconciledTS (split, ts.tv_sec);
-                }//if
-                qof_print_date_buff (datebuff, sizeof(datebuff), 0);
+                time64 t = xaccSplitGetDateReconciled (split);
+                qof_print_date_buff (datebuff, sizeof(datebuff), t);
             }
             editable = FALSE;
         }
@@ -1870,7 +1861,6 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
         if (is_trow2)
         {
             s = "";
-            editable = FALSE;
         }
         else if (is_trow1) // Value
         {
@@ -1878,12 +1868,8 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
             {
                 Split *this_split;
 
-                this_split = gtv_sr_get_this_split (view, trans);
-
                 num = xaccTransGetAccountValue (trans, anchor);
 
-                editable = !expanded && !gnc_tree_util_split_reg_is_multi (this_split);
-
                 if (expanded)
                     s = "";
                 else
@@ -1892,7 +1878,6 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
             else
             {
                 s = "";
-                editable = FALSE;
             }
         }
 
@@ -1902,7 +1887,6 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
             {
                 num = xaccSplitGetAmount (split);
                 s = xaccPrintAmount (num, gnc_account_print_info (xaccSplitGetAccount (split), SHOW_SYMBOL));
-                editable = TRUE;
             }
             else if (anchor)
             {
@@ -1913,13 +1897,11 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
                 {
                     num = xaccSplitGetAmount (split);
                     s = xaccPrintAmount (num, gnc_account_print_info (xaccSplitGetAccount (split), SHOW_SYMBOL));
-                    editable = TRUE;
                 }
             }
             else
             {
                 s = "";
-                editable = FALSE;
             }
 
             if (gtv_sr_get_imbalance (trans))
@@ -1945,14 +1927,12 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
         if (is_trow2)
         {
             s = "";
-            editable = FALSE;
         }
         else if (is_trow1)
         {
             if (expanded)
             {
                 s = "";
-                editable = FALSE;
             }
             else
             {
@@ -1968,22 +1948,18 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
                         else
                             num = xaccSplitGetSharePrice (this_split);
 
-                        editable = !expanded && !gnc_tree_util_split_reg_is_multi (this_split);
-
-                        if (gnc_numeric_check (num) == GNC_ERROR_OK)
+                         if (gnc_numeric_check (num) == GNC_ERROR_OK)
                         {
                             s = xaccPrintAmount (num, gnc_split_amount_print_info (split, SHOW_SYMBOL));
                         }
                         else
                         {
                             s = "";
-                            editable = FALSE;
                         }
                     }
                     else
                     {
                         s = "";
-                        editable = FALSE;
                     }
                 }
             }
@@ -2001,18 +1977,15 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
                 if (gnc_numeric_check (num) == GNC_ERROR_OK)
                 {
                     s = xaccPrintAmount (num, gnc_split_amount_print_info (split, SHOW_SYMBOL));
-                    editable = TRUE;
                 }
                 else
                 {
                     s = "";
-                    editable = FALSE;
                 }
             }
             else
             {
                 s = "";
-                editable = FALSE;
             }
 
             if (gtv_sr_get_imbalance (trans))
@@ -2041,7 +2014,6 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
                     if (!gnc_tree_util_split_reg_get_debcred_entry (view, trans, split, is_blank, &num, &print_info))
                         num = gnc_numeric_zero();
 
-                    editable = TRUE;
                     if (gtv_sr_get_imbalance (trans))
                         g_object_set (cell, "cell-background", PINKCELL, (gchar*)NULL);
                 }
@@ -2049,18 +2021,15 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
                 {
                     if (anchor)
                     {
-                         editable = !expanded && !gnc_tree_util_split_reg_is_multi (gtv_sr_get_this_split (view, trans));
                          num = xaccTransGetAccountAmount (trans, anchor);
                     }
                     else
                     {
-                        editable = FALSE;
                         num = gnc_numeric_zero();
                     }
                 }
                 else if (is_trow2)
                 {
-                    editable = FALSE;
                     num = gnc_numeric_zero();
                 }
 
@@ -2081,12 +2050,10 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
             }
             else
             {
-                editable = TRUE;
 
                 if (is_trow1 || is_trow2)
                 {
                     s = "";
-                    editable = FALSE;
                 }
                 else if (is_split && viewcol == COL_DEBIT)
                     s = gnc_tree_util_split_reg_template_get_fdebt_entry (split);
@@ -4031,8 +3998,6 @@ gtv_sr_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
                 g_free (string);
             }
 
-            model = gnc_tree_view_split_reg_get_model_from_view (view);
-
             /* Step to the next column, we may wrap */
             gnc_tree_view_keynav (GNC_TREE_VIEW (view), &col, spath, event); // returns path and column
 
diff --git a/gnucash/gnome-utils/gnc-tree-view.c b/gnucash/gnome-utils/gnc-tree-view.c
index 9ed22c6..cd93a18 100644
--- a/gnucash/gnome-utils/gnc-tree-view.c
+++ b/gnucash/gnome-utils/gnc-tree-view.c
@@ -1652,7 +1652,6 @@ gnc_tree_view_column_properties (GncTreeView *view,
     }
     else
     {
-        priv = GNC_TREE_VIEW_GET_PRIVATE(view);
 
         /* If saved state comes back with a width of zero (or there is no saved
          * state width) the use the default width for the column.  Allow for
diff --git a/gnucash/gnome/dialog-billterms.c b/gnucash/gnome/dialog-billterms.c
index 38bb656..e42d2fe 100644
--- a/gnucash/gnome/dialog-billterms.c
+++ b/gnucash/gnome/dialog-billterms.c
@@ -270,11 +270,6 @@ verify_term_ok (NewBillTerm *nbt)
     gint days_due_days, days_disc_days;
     gint prox_due_days, prox_disc_days;
 
-    days_due_days=0;
-    days_disc_days=0;
-    prox_due_days=0;
-    prox_disc_days=0;
-
     notebook = &nbt->notebook;
     result=TRUE;
 
diff --git a/gnucash/gnome/dialog-payment.c b/gnucash/gnome/dialog-payment.c
index 47f4da3..b1f9652 100644
--- a/gnucash/gnome/dialog-payment.c
+++ b/gnucash/gnome/dialog-payment.c
@@ -446,10 +446,8 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
         for (node = pw->tx_info->lots; node; node = node->next)
         {
             PreExistLotInfo *lot_info = node->data;
-            if (!gnc_numeric_zero_p (gnc_lot_get_balance (lot_info->lot)))
-                /* This case will be handled below when the lot is processed as part of the open lots */
-                tx_lot = lot_info->lot;
-            else
+            if (gnc_numeric_zero_p (gnc_lot_get_balance (lot_info->lot)))
+                /* The not-zero case will be handled below when the lot is processed as part of the open lots */
             {
                 GncOwner lotowner;
                 gncOwnerInitUndefined(&lotowner, NULL);
@@ -486,7 +484,7 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
         const gchar *doc_cred_str = NULL;
         GtkTreeIter iter;
         GncInvoice *document;
-        gnc_numeric value = gnc_numeric_zero();
+        gnc_numeric value;
         gnc_numeric debit = gnc_numeric_zero();
         gnc_numeric credit = gnc_numeric_zero();
 
diff --git a/gnucash/gnome/dialog-price-edit-db.c b/gnucash/gnome/dialog-price-edit-db.c
index 9c001ec..602a9cd 100644
--- a/gnucash/gnome/dialog-price-edit-db.c
+++ b/gnucash/gnome/dialog-price-edit-db.c
@@ -429,7 +429,7 @@ gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data)
     gtk_cell_renderer_set_alignment (cr, 0.5, 0.5);
 
     // Load the view and get the earliest date
-    first = gnc_prices_dialog_load_view (pdb_dialog->remove_view, pdb_dialog->price_db);
+    gnc_prices_dialog_load_view (pdb_dialog->remove_view, pdb_dialog->price_db);
     gtk_tree_selection_select_all (selection);
     g_signal_connect (selection, "changed", G_CALLBACK(selection_changed_cb), pdb_dialog);
 
diff --git a/gnucash/gnome/dialog-sx-editor.c b/gnucash/gnome/dialog-sx-editor.c
index c4c667e..cb97424 100644
--- a/gnucash/gnome/dialog-sx-editor.c
+++ b/gnucash/gnome/dialog-sx-editor.c
@@ -636,7 +636,7 @@ gnc_sxed_split_check_account (GncSxEditorDialog *sxed, Split *s,
                      gnc_commodity *base_cmdty, gboolean *multi_cmdty)
 {
     gnc_commodity *split_cmdty = NULL;
-    gnc_numeric split_amount = gnc_numeric_zero ();
+    gnc_numeric split_amount;
     Account *acct = NULL;
     GncGUID *acct_guid = NULL;
     qof_instance_get (QOF_INSTANCE (s),
diff --git a/gnucash/gnome/dialog-sx-editor2.c b/gnucash/gnome/dialog-sx-editor2.c
index 208773d..5237c15 100644
--- a/gnucash/gnome/dialog-sx-editor2.c
+++ b/gnucash/gnome/dialog-sx-editor2.c
@@ -514,7 +514,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed)
 {
     gboolean multi_commodity = FALSE;
     gnc_commodity *base_cmdty = NULL;
-    gint ttVarCount, splitCount;
+    gint ttVarCount, splitCount = 0;
     GList *schedule = NULL;
 
     /* Do checks on validity and such, interrupting the user if
@@ -536,8 +536,6 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed)
      *   right... ]
      */
 
-    ttVarCount = 0;
-    splitCount = 0;
     {
         static const int NUM_ITERS_WITH_VARS = 5;
         static const int NUM_ITERS_NO_VARS = 1;
diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index cf6f357..5aed86e 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -913,7 +913,7 @@ budget_total_col_source(Account *account, GtkTreeViewColumn *col,
                         GtkCellRenderer *cell)
 {
     GncBudget *budget;
-    gnc_numeric total = gnc_numeric_zero();
+    gnc_numeric total;
     gchar amtbuff[100]; //FIXME: overkill, where's the #define?
 
     budget = GNC_BUDGET(g_object_get_data(G_OBJECT(col), "budget"));
diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c
index c019f28..cf90aaf 100644
--- a/gnucash/gnome/gnc-plugin-page-register.c
+++ b/gnucash/gnome/gnc-plugin-page-register.c
@@ -857,7 +857,6 @@ gnc_plugin_page_register_focus (GncPluginPageRegister *page)
 {
     if (GNC_IS_PLUGIN_PAGE_REGISTER(page))
     {
-        GncPluginPageRegisterPrivate *priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
         GNCSplitReg *gsr = gnc_plugin_page_register_get_gsr(GNC_PLUGIN_PAGE(page));
         gnc_split_reg_focus_on_sheet (gsr);
     }
@@ -3121,7 +3120,6 @@ gnc_plugin_page_register_set_filter_tooltip (GncPluginPageRegister *page)
 
     ENTER(" ");
     priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
-    plugin_page = GNC_PLUGIN_PAGE(page);
 
     // filtered start time
     if (priv->fd.start_time != 0)
diff --git a/gnucash/gnome/gnc-plugin-page-register2.c b/gnucash/gnome/gnc-plugin-page-register2.c
index 63cce2d..a3f6db2 100644
--- a/gnucash/gnome/gnc-plugin-page-register2.c
+++ b/gnucash/gnome/gnc-plugin-page-register2.c
@@ -2870,7 +2870,6 @@ gnc_plugin_page_register2_cmd_void_transaction (GtkAction *action,
     }
     if (xaccTransHasReconciledSplits (trans) || xaccTransHasSplitsInState (trans, CREC))
     {
-        GtkWindow *window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)));
         gnc_error_dialog (NULL, "%s", _("You cannot void a transaction with reconciled or cleared splits."));
         LEAVE("trans with reconciled splits");
         return;
diff --git a/gnucash/gnome/gnc-split-reg2.c b/gnucash/gnome/gnc-split-reg2.c
index edf20f4..807e439 100644
--- a/gnucash/gnome/gnc-split-reg2.c
+++ b/gnucash/gnome/gnc-split-reg2.c
@@ -560,9 +560,6 @@ gsr2_redraw_all_cb (GncTreeViewSplitReg *view, gpointer user_data)
     if (gsr->value_label != NULL)
     {
         char string[256];
-        QofBook *book = gnc_account_get_book (leader);
-        GNCPriceDB *pricedb = gnc_pricedb_get_db (book);
-        gnc_commodity *commodity = xaccAccountGetCommodity (leader);
         gnc_commodity *currency = gnc_default_currency ();
         print_info = gnc_commodity_print_info (currency, TRUE);
         xaccSPrintAmount (string, amount, print_info);
diff --git a/gnucash/gnome/reconcile-view.c b/gnucash/gnome/reconcile-view.c
index 382807a..77ace81 100644
--- a/gnucash/gnome/reconcile-view.c
+++ b/gnucash/gnome/reconcile-view.c
@@ -174,9 +174,7 @@ gnc_reconcile_view_tooltip_cb (GNCQueryView *qview, gint x, gint y,
 
                 gdk_window_get_origin (parent_window, &root_x, &root_y);
 
-                screen = gtk_widget_get_screen (GTK_WIDGET (qview));
-
-                /* Get a list of toplevel windows */
+                 /* Get a list of toplevel windows */
                 win_list = gtk_window_list_toplevels ();
 
                 /* Look for the gtk-tooltip window, we do this as gtk_widget_get_tooltip_window
diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c
index df61d15..cdec7b9 100644
--- a/gnucash/gnome/window-reconcile.c
+++ b/gnucash/gnome/window-reconcile.c
@@ -584,7 +584,7 @@ gnc_reconcile_interest_xfer_run(startRecnWindowData *data)
                            GNC_AMOUNT_EDIT(data->end_value) );
     gnc_numeric before = gnc_amount_edit_get_amount(
                              GNC_AMOUNT_EDIT(data->end_value) );
-    gnc_numeric after = gnc_numeric_zero();
+    gnc_numeric after;
 
     recnInterestXferWindow( data );
 
@@ -937,6 +937,9 @@ do_popup_menu(RecnWindow *recnData, GdkEventButton *event)
         return;
     }
 
+#if GTK_CHECK_VERSION(3,22,0)
+    gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event);
+#else
     if (event)
     {
         button = event->button;
@@ -948,9 +951,6 @@ do_popup_menu(RecnWindow *recnData, GdkEventButton *event)
         event_time = gtk_get_current_event_time ();
     }
 
-#if GTK_CHECK_VERSION(3,22,0)
-    gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event);
-#else
     gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, event_time);
 #endif
 }
diff --git a/gnucash/gnome/window-reconcile2.c b/gnucash/gnome/window-reconcile2.c
index 50cdf74..96648f5 100644
--- a/gnucash/gnome/window-reconcile2.c
+++ b/gnucash/gnome/window-reconcile2.c
@@ -544,7 +544,7 @@ gnc_reconcile_interest_xfer_run (startRecnWindowData *data)
                            GNC_AMOUNT_EDIT(data->end_value));
     gnc_numeric before = gnc_amount_edit_get_amount (
                              GNC_AMOUNT_EDIT(data->end_value));
-    gnc_numeric after = gnc_numeric_zero();
+    gnc_numeric after;
 
     recnInterestXferWindow (data);
 
@@ -896,6 +896,9 @@ do_popup_menu (RecnWindow2 *recnData, GdkEventButton *event)
         return;
     }
 
+#if GTK_CHECK_VERSION(3,22,0)
+    gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event);
+#else
     if (event)
     {
         button = event->button;
@@ -907,9 +910,6 @@ do_popup_menu (RecnWindow2 *recnData, GdkEventButton *event)
         event_time = gtk_get_current_event_time ();
     }
 
-#if GTK_CHECK_VERSION(3,22,0)
-    gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event);
-#else
     gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, event_time);
 #endif
 }
diff --git a/gnucash/import-export/aqb/dialog-ab-trans.c b/gnucash/import-export/aqb/dialog-ab-trans.c
index 5f28d57..4f6bf42 100644
--- a/gnucash/import-export/aqb/dialog-ab-trans.c
+++ b/gnucash/import-export/aqb/dialog-ab-trans.c
@@ -983,12 +983,11 @@ gnc_ab_trans_dialog_templ_list_row_activated_cb(GtkTreeView *view,
     GncABTransDialog *td = user_data;
     GtkTreeIter iter;
     GncABTransTempl *templ;
-    const gchar *old_name, *new_name;
-    const gchar *old_account, *new_account;
-    const gchar *old_bankcode, *new_bankcode;
-    const gchar *old_purpose, *new_purpose;
-    const gchar *old_purpose_cont, *new_purpose_cont;
-    GtkWidget *amount_widget;
+    const gchar *new_name;
+    const gchar *new_account;
+    const gchar *new_bankcode;
+    const gchar *new_purpose;
+    const gchar *new_purpose_cont;
     const gchar *old_amount_text;
     gnc_numeric old_amount, new_amount;
 
@@ -1004,16 +1003,6 @@ gnc_ab_trans_dialog_templ_list_row_activated_cb(GtkTreeView *view,
     gtk_tree_model_get(GTK_TREE_MODEL(td->template_list_store), &iter,
                        TEMPLATE_POINTER, &templ, -1);
 
-    /* Get old values */
-    old_name = gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry));
-    old_account = gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry));
-    old_bankcode = gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry));
-    old_purpose = gtk_entry_get_text(GTK_ENTRY(td->purpose_entry));
-    old_purpose_cont = gtk_entry_get_text(GTK_ENTRY(td->purpose_cont_entry));
-    amount_widget = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit));
-    old_amount_text = gtk_entry_get_text(GTK_ENTRY(amount_widget));
-    old_amount = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(td->amount_edit));
-
     /* Get new values */
     new_name = gnc_ab_trans_templ_get_recp_name(templ);
     new_account = gnc_ab_trans_templ_get_recp_account(templ);
diff --git a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
index 9676616..175ec7c 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
@@ -401,7 +401,7 @@ set_commodity_for_combo (GtkComboBox *combo, gnc_commodity *comm)
         valid = gtk_tree_model_iter_next (model, &iter);
     }
     // Not found, set it to first iter
-    valid = gtk_tree_model_get_iter_first (model, &iter);
+    gtk_tree_model_get_iter_first (model, &iter);
     if (gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT(sort_model), &siter, &iter))
         gtk_combo_box_set_active_iter (combo, &siter);
 }
@@ -829,7 +829,6 @@ CsvImpPriceAssist::preview_settings_delete ()
 void
 CsvImpPriceAssist::preview_settings_save ()
 {
-    auto title = _("Save the Import Settings.");
     auto new_name = price_imp->settings_name();
 
     /* Check if the entry text matches an already existing preset */
diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
index 26fd355..a0f8b11 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
@@ -1741,7 +1741,6 @@ csv_tximp_acct_match_text_parse (std::string acct_name)
             alt_sep = "-";
         else
             alt_sep = ":";
-        sep_pos = acct_name.find(sep);
         for (sep_pos = acct_name.find(sep); sep_pos != std::string::npos;
                 sep_pos = acct_name.find(sep))
             acct_name.replace (sep_pos, strlen(sep), alt_sep);
diff --git a/gnucash/import-export/log-replay/gnc-log-replay.c b/gnucash/import-export/log-replay/gnc-log-replay.c
index 34d135a..a3f3eca 100644
--- a/gnucash/import-export/log-replay/gnc-log-replay.c
+++ b/gnucash/import-export/log-replay/gnc-log-replay.c
@@ -639,7 +639,6 @@ void gnc_file_log_replay (GtkWindow *parent)
                     {
                         do
                         {
-                            read_retval = fgets(read_buf, sizeof(read_buf), log_file);
                             /*DEBUG("Chunk read: %s",read_retval);*/
                             if (strncmp(record_start_str, read_buf, strlen(record_start_str)) == 0) /* If a record started */
                             {
diff --git a/gnucash/register/ledger-core/split-register-load.c b/gnucash/register/ledger-core/split-register-load.c
index d5286ad..37e90fb 100644
--- a/gnucash/register/ledger-core/split-register-load.c
+++ b/gnucash/register/ledger-core/split-register-load.c
@@ -673,7 +673,6 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
             !found_divider_upper && need_divider_upper)
     {
         table->model->dividing_row_upper = vcell_loc.virt_row;
-        found_divider_upper = TRUE;
     }
 
     /* If we didn't find the pending transaction, it was removed
diff --git a/gnucash/register/ledger-core/split-register-model-save.c b/gnucash/register/ledger-core/split-register-model-save.c
index d4b24db..8cad2f1 100644
--- a/gnucash/register/ledger-core/split-register-model-save.c
+++ b/gnucash/register/ledger-core/split-register-model-save.c
@@ -549,7 +549,7 @@ gnc_split_register_save_cells (gpointer save_data,
     SplitRegister *reg = user_data;
     Split *other_split;
     gnc_commodity *txn_cur;
-    gnc_numeric rate = gnc_numeric_zero();
+    gnc_numeric rate;
 
     g_return_if_fail (sd != NULL);
 
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index bc83f09..dd8c103 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -55,7 +55,7 @@ gnc_split_register_get_rbaln (VirtualLocation virt_loc, gpointer user_data, gboo
     SplitRegister *reg = user_data;
     Split *split;
     SRInfo *info = gnc_split_register_get_info (reg);
-    gnc_numeric balance = gnc_numeric_zero();
+    gnc_numeric balance;
     Account *account = NULL;
     Transaction *trans;
     GList *node, *child;
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 9d71d8e..fc8120d 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -693,8 +693,6 @@ gnc_combo_cell_direct_update (BasicCell *bcell,
         }
     }
 
-    new_pos = *cursor_position;
-
     if (find_pos >= 0)
     {
         new_pos = find_pos;
diff --git a/gnucash/register/register-gnome/gnucash-header.c b/gnucash/register/register-gnome/gnucash-header.c
index 017a496..bf2f600 100644
--- a/gnucash/register/register-gnome/gnucash-header.c
+++ b/gnucash/register/register-gnome/gnucash-header.c
@@ -462,8 +462,6 @@ gnc_header_event (GtkWidget *widget, GdkEvent *event)
         if (event->button.button != 1)
             break;
 
-        x = event->button.x;
-        y = event->button.y;
 
         if (header->in_resize)
         {
diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index fc5d7b3..c4799a2 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -913,7 +913,6 @@ check_popup_height_is_true (GtkWidget    *widget,
                             gpointer user_data)
 {
     GncItemEdit *item_edit = GNC_ITEM_EDIT(user_data);
-    GnucashSheet *sheet = item_edit->sheet;
 
     // if a larger font is specified in css for the sheet, the popup returned height value
     // on first pop does not reflect the true height but the minimum height so just to be
@@ -955,7 +954,6 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
 
     gtk_widget_get_allocation (GTK_WIDGET (sheet), &alloc);
     view_height = alloc.height;
-    view_width  = alloc.width;
 
     vadj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(sheet));
     hadj = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(sheet));
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 38811b2..1e22ff2 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -335,7 +335,7 @@ gnucash_sheet_get_text_cursor_position (GnucashSheet *sheet, const VirtualLocati
     x_offset = gnucash_sheet_get_text_offset (sheet, virt_loc,
                                               rect.width, logical_rect.width);
 
-    result = pango_layout_xy_to_index (layout,
+    pango_layout_xy_to_index (layout,
                  PANGO_SCALE * (sheet->button_x - rect.x - x_offset),
                  PANGO_SCALE * (height/2), &index, &trailing);
 
@@ -1169,7 +1169,7 @@ gnucash_sheet_draw_cb (GtkWidget *widget, cairo_t *cr, G_GNUC_UNUSED gpointer da
     gtk_style_context_restore (context);
 
 //FIXME what should be done with result being TRUE or FALSE
-    result = gnucash_sheet_draw_internal (sheet, cr, &alloc);
+    gnucash_sheet_draw_internal (sheet, cr, &alloc);
     gnucash_sheet_draw_cursor (sheet->cursor, cr);
 
     return FALSE;
@@ -1531,7 +1531,7 @@ gnucash_sheet_button_press_event (GtkWidget *widget, GdkEventButton *event)
         return TRUE;
 
 //FIXME does something need to be done if changed_cells is true or false ?
-    changed_cells = gnucash_sheet_cursor_move (sheet, new_virt_loc);
+    gnucash_sheet_cursor_move (sheet, new_virt_loc);
 
     if (button_1)
         gnucash_sheet_check_grab (sheet);
diff --git a/gnucash/register/register-gnome/gnucash-style.c b/gnucash/register/register-gnome/gnucash-style.c
index cecbda0..f2a04fb 100644
--- a/gnucash/register/register-gnome/gnucash-style.c
+++ b/gnucash/register/register-gnome/gnucash-style.c
@@ -228,7 +228,7 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
             cd->pixel_width = MAX (cd->pixel_width, width);
         }
 
-        cd = g_table_index (dimensions->cell_dimensions, row, 0);
+        g_table_index (dimensions->cell_dimensions, row, 0);
         dimensions->height += max_height;
     }
 
@@ -294,7 +294,6 @@ set_dimensions_pass_two (GnucashSheet *sheet, int default_width)
             cd = g_table_index (cd_table, 0, col);
 
             cd->pixel_width += (default_width - width);
-            width += (default_width - width);
             widths[col] = cd->pixel_width;
 
             break;
@@ -316,8 +315,6 @@ set_dimensions_pass_two (GnucashSheet *sheet, int default_width)
 
             cd = g_table_index (cd_table, 0, col);
 
-            old_width = cd->pixel_width;
-
             cd->pixel_width += (default_width - width);
 
             text = cell->sample_text;
@@ -335,7 +332,6 @@ set_dimensions_pass_two (GnucashSheet *sheet, int default_width)
 
             cd->pixel_width = MAX (cd->pixel_width, sample_width);
 
-            width += cd->pixel_width - old_width;
             widths[col] = cd->pixel_width;
 
             break;
diff --git a/libgnucash/app-utils/calculation/fin.c b/libgnucash/app-utils/calculation/fin.c
index a0235ff..3c04118 100644
--- a/libgnucash/app-utils/calculation/fin.c
+++ b/libgnucash/app-utils/calculation/fin.c
@@ -1675,7 +1675,6 @@ Amortization_init (amort_sched_ptr amortsched)
 
     if (pmt == 0.0)
     {
-        s = 0;
         amortsched->pve = pv;
     }
     else
@@ -1854,8 +1853,6 @@ Amortization_Schedule (amort_sched_ptr amortsched)
         amortsched->schedule.first_yr =
             amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
 
-        d = pv;
-
         for (per_cnt = 0, s = 1, j = n; pv != fv; j -= 2, per_cnt++)
         {
             /* basic equation to compute interest this payment period */
@@ -1999,8 +1996,6 @@ Amortization_Schedule (amort_sched_ptr amortsched)
         amortsched->schedule.first_yr =
             amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
 
-        d = pv;
-
         /*  set advnaced payment */
         adv_pmt = amortsched->fixed_pmt;
 
diff --git a/libgnucash/app-utils/gnc-exp-parser.c b/libgnucash/app-utils/gnc-exp-parser.c
index 2e303f9..38c0119 100644
--- a/libgnucash/app-utils/gnc-exp-parser.c
+++ b/libgnucash/app-utils/gnc-exp-parser.c
@@ -568,7 +568,6 @@ gnc_exp_parser_parse_separate_vars (const char * expression,
         newVars = parser_get_vars( pe );
         for ( ; newVars ; newVars = newVars->next_var )
         {
-            pnum = newVars->value;
             if ( g_hash_table_lookup_extended( varHash, newVars->variable_name,
                                                &maybeKey, &maybeValue ) )
             {
diff --git a/libgnucash/app-utils/gnc-ui-util.c b/libgnucash/app-utils/gnc-ui-util.c
index 1c5f78d..017befc 100644
--- a/libgnucash/app-utils/gnc-ui-util.c
+++ b/libgnucash/app-utils/gnc-ui-util.c
@@ -1857,7 +1857,6 @@ integer_to_words(gint64 val)
     if (val > 0)
     {
         this_part = val;
-        val -= this_part;
         g_string_append(result, gettext(small_numbers[this_part]));
         g_string_append_c(result, ' ');
     }
diff --git a/libgnucash/app-utils/option-util.c b/libgnucash/app-utils/option-util.c
index 4ec1ba1..802bbad 100644
--- a/libgnucash/app-utils/option-util.c
+++ b/libgnucash/app-utils/option-util.c
@@ -1134,7 +1134,6 @@ gboolean gnc_option_get_range_info(GNCOption *option,
 
     /* step size */
     value = SCM_CAR(list);
-    list = SCM_CDR(list);
 
     if (!scm_is_number(value))
         return FALSE;
@@ -1694,7 +1693,7 @@ gnc_commit_option(GNCOption *option)
     {
         SCM oops;
         char *section, *name;
-        const char *message;
+        const char *message = NULL;
         const char *format = _("There is a problem with option %s:%s.\n%s");
         const char *bad_value = _("Invalid option value");
 
@@ -1711,13 +1710,14 @@ gnc_commit_option(GNCOption *option)
                                      name ? name : "(null)",
                                      bad_value);
         }
-
-        message = gnc_scm_to_utf8_string (oops);
-        retval = g_strdup_printf(format,
-                                 section ? section : "(null)",
-                                 name ? name : "(null)",
-                                 message ? message : "(null)");
-
+        else
+        {
+            message = gnc_scm_to_utf8_string (oops);
+            retval = g_strdup_printf(format,
+                                     section ? section : "(null)",
+                                     name ? name : "(null)",
+                                     message ? message : "(null)");
+        }
         if (name != NULL)
             free(name);
         if (section != NULL)
diff --git a/libgnucash/backend/dbi/gnc-backend-dbi.cpp b/libgnucash/backend/dbi/gnc-backend-dbi.cpp
index b3d9d2a..0d547e4 100644
--- a/libgnucash/backend/dbi/gnc-backend-dbi.cpp
+++ b/libgnucash/backend/dbi/gnc-backend-dbi.cpp
@@ -205,7 +205,7 @@ set_options(dbi_conn conn, const PairVec& options)
         if (result < 0)
         {
             const char *msg = nullptr;
-            int err = dbi_conn_error(conn, &msg);
+            dbi_conn_error(conn, &msg);
             PERR("Error setting %s option to %s: %s", opt, val, msg);
             throw std::runtime_error(msg);
         }
diff --git a/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp b/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp
index 0c7e854..2577fe6 100644
--- a/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp
+++ b/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp
@@ -542,8 +542,8 @@ GncDbiSqlConnection::quote_string (const std::string& unquoted_str)
     char* quoted_str;
     size_t size;
 
-    size = dbi_conn_quote_string_copy (m_conn, unquoted_str.c_str(),
-                                       &quoted_str);
+    dbi_conn_quote_string_copy (m_conn, unquoted_str.c_str(),
+                                &quoted_str);
     if (quoted_str == nullptr)
         return std::string{""};
     std::string retval{quoted_str};
diff --git a/libgnucash/backend/dbi/gnc-dbisqlresult.cpp b/libgnucash/backend/dbi/gnc-dbisqlresult.cpp
index 0436c07..b045056 100644
--- a/libgnucash/backend/dbi/gnc-dbisqlresult.cpp
+++ b/libgnucash/backend/dbi/gnc-dbisqlresult.cpp
@@ -144,7 +144,7 @@ std::string
 GncDbiSqlResult::IteratorImpl::get_string_at_col(const char* col) const
 {
     auto type = dbi_result_get_field_type (m_inst->m_dbi_result, col);
-    auto attrs = dbi_result_get_field_attribs (m_inst->m_dbi_result, col);
+    dbi_result_get_field_attribs (m_inst->m_dbi_result, col);
     if(type != DBI_TYPE_STRING)
         throw (std::invalid_argument{"Requested string from non-string column."});
     auto strval = dbi_result_get_string(m_inst->m_dbi_result, col);
@@ -160,7 +160,7 @@ GncDbiSqlResult::IteratorImpl::get_time64_at_col (const char* col) const
 {
     auto result = (dbi_result_t*) (m_inst->m_dbi_result);
     auto type = dbi_result_get_field_type (result, col);
-    auto attrs = dbi_result_get_field_attribs (result, col);
+    dbi_result_get_field_attribs (result, col);
     if (type != DBI_TYPE_DATETIME)
         throw (std::invalid_argument{"Requested time64 from non-time64 column."});
 #if HAVE_LIBDBI_TO_LONGLONG
diff --git a/libgnucash/backend/sql/gnc-bill-term-sql.cpp b/libgnucash/backend/sql/gnc-bill-term-sql.cpp
index 31b4445..5f598f9 100644
--- a/libgnucash/backend/sql/gnc-bill-term-sql.cpp
+++ b/libgnucash/backend/sql/gnc-bill-term-sql.cpp
@@ -244,8 +244,7 @@ GncSqlBillTermBackend::load_all (GncSqlBackend* sql_be)
 
     for (auto row : *result)
     {
-        auto pBillTerm =
-            load_single_billterm (sql_be, row, l_billterms_needing_parents);
+        load_single_billterm (sql_be, row, l_billterms_needing_parents);
     }
     delete result;
     std::string pkey(col_table[0]->name());
diff --git a/libgnucash/backend/sql/gnc-budget-sql.cpp b/libgnucash/backend/sql/gnc-budget-sql.cpp
index 564c3db..67ecb3a 100644
--- a/libgnucash/backend/sql/gnc-budget-sql.cpp
+++ b/libgnucash/backend/sql/gnc-budget-sql.cpp
@@ -333,7 +333,7 @@ GncSqlBudgetBackend::load_all (GncSqlBackend* sql_be)
     auto stmt = sql_be->create_statement_from_sql(sql);
     auto result = sql_be->execute_select_statement(stmt);
     for (auto row : *result)
-        auto b = load_single_budget (sql_be, row);
+        load_single_budget (sql_be, row);
 
     std::string pkey(col_table[0]->name());
     sql = "SELECT DISTINCT ";
diff --git a/libgnucash/backend/sql/gnc-customer-sql.cpp b/libgnucash/backend/sql/gnc-customer-sql.cpp
index d4c2bfa..6d3d84a 100644
--- a/libgnucash/backend/sql/gnc-customer-sql.cpp
+++ b/libgnucash/backend/sql/gnc-customer-sql.cpp
@@ -134,7 +134,7 @@ GncSqlCustomerBackend::load_all (GncSqlBackend* sql_be)
     auto result = sql_be->execute_select_statement(stmt);
 
     for (auto row : *result)
-        GncCustomer* pCustomer = load_single_customer (sql_be, row);
+        load_single_customer (sql_be, row);
 
     std::string pkey(col_table[0]->name());
     sql = "SELECT DISTINCT ";
diff --git a/libgnucash/backend/sql/gnc-employee-sql.cpp b/libgnucash/backend/sql/gnc-employee-sql.cpp
index afa0e90..20c7fb5 100644
--- a/libgnucash/backend/sql/gnc-employee-sql.cpp
+++ b/libgnucash/backend/sql/gnc-employee-sql.cpp
@@ -118,7 +118,7 @@ GncSqlEmployeeBackend::load_all (GncSqlBackend* sql_be)
     auto result = sql_be->execute_select_statement(stmt);
 
     for (auto row : *result)
-        GncEmployee* pEmployee = load_single_employee (sql_be, row);
+        load_single_employee (sql_be, row);
 
     std::string pkey(col_table[0]->name());
     sql = "SELECT DISTINCT ";
diff --git a/libgnucash/backend/sql/gnc-entry-sql.cpp b/libgnucash/backend/sql/gnc-entry-sql.cpp
index b22bc55..554a50e 100644
--- a/libgnucash/backend/sql/gnc-entry-sql.cpp
+++ b/libgnucash/backend/sql/gnc-entry-sql.cpp
@@ -203,7 +203,7 @@ GncSqlEntryBackend::load_all (GncSqlBackend* sql_be)
     auto result = sql_be->execute_select_statement(stmt);
 
     for (auto row : *result)
-        GncEntry* pEntry = load_single_entry (sql_be, row);
+        load_single_entry (sql_be, row);
 
     std::string pkey(col_table[0]->name());
     sql = "SELECT DISTINCT ";
diff --git a/libgnucash/backend/sql/gnc-invoice-sql.cpp b/libgnucash/backend/sql/gnc-invoice-sql.cpp
index b134bc7..adfbeba 100644
--- a/libgnucash/backend/sql/gnc-invoice-sql.cpp
+++ b/libgnucash/backend/sql/gnc-invoice-sql.cpp
@@ -141,7 +141,7 @@ GncSqlInvoiceBackend::load_all (GncSqlBackend* sql_be)
     auto result = sql_be->execute_select_statement(stmt);
 
     for (auto row : *result)
-        GncInvoice* pInvoice = load_single_invoice (sql_be, row);
+        load_single_invoice (sql_be, row);
 
     std::string pkey(col_table[0]->name());
     sql = "SELECT DISTINCT ";
diff --git a/libgnucash/backend/sql/gnc-job-sql.cpp b/libgnucash/backend/sql/gnc-job-sql.cpp
index 48e17aa..c688271 100644
--- a/libgnucash/backend/sql/gnc-job-sql.cpp
+++ b/libgnucash/backend/sql/gnc-job-sql.cpp
@@ -113,7 +113,7 @@ GncSqlJobBackend::load_all (GncSqlBackend* sql_be)
     auto result = sql_be->execute_select_statement(stmt);
 
     for (auto row : *result)
-        GncJob* pJob = load_single_job (sql_be, row);
+        load_single_job (sql_be, row);
 
     std::string pkey(col_table[0]->name());
     sql = "SELECT DISTINCT ";
diff --git a/libgnucash/backend/sql/gnc-order-sql.cpp b/libgnucash/backend/sql/gnc-order-sql.cpp
index 453a7a4..e339e02 100644
--- a/libgnucash/backend/sql/gnc-order-sql.cpp
+++ b/libgnucash/backend/sql/gnc-order-sql.cpp
@@ -115,7 +115,7 @@ GncSqlOrderBackend::load_all (GncSqlBackend* sql_be)
     auto result = sql_be->execute_select_statement(stmt);
 
     for (auto row : *result)
-        GncOrder* pOrder = load_single_order (sql_be, row);
+        load_single_order (sql_be, row);
 
     std::string pkey(col_table[0]->name());
     sql = "SELECT DISTINCT ";
diff --git a/libgnucash/backend/sql/gnc-sql-backend.cpp b/libgnucash/backend/sql/gnc-sql-backend.cpp
index 3e31d4c..270c06e 100644
--- a/libgnucash/backend/sql/gnc-sql-backend.cpp
+++ b/libgnucash/backend/sql/gnc-sql-backend.cpp
@@ -508,7 +508,7 @@ GncSqlBackend::sync(QofBook* book)
     else
     {
         set_error (ERR_BACKEND_SERVER_ERR);
-        is_ok = m_conn->rollback_transaction ();
+        m_conn->rollback_transaction ();
     }
     finish_progress();
     LEAVE ("book=%p", book);
diff --git a/libgnucash/backend/sql/gnc-transaction-sql.cpp b/libgnucash/backend/sql/gnc-transaction-sql.cpp
index 16f9820..9867577 100644
--- a/libgnucash/backend/sql/gnc-transaction-sql.cpp
+++ b/libgnucash/backend/sql/gnc-transaction-sql.cpp
@@ -216,7 +216,6 @@ load_single_split (GncSqlBackend* sql_be, GncSqlRow& row)
     if (guid_equal (guid, guid_null ()))
     {
         PWARN ("Bad GUID, creating new");
-        bad_guid = TRUE;
         split_guid = guid_new_return ();
     }
     else
diff --git a/libgnucash/backend/sql/gnc-vendor-sql.cpp b/libgnucash/backend/sql/gnc-vendor-sql.cpp
index a73c29c..11b2768 100644
--- a/libgnucash/backend/sql/gnc-vendor-sql.cpp
+++ b/libgnucash/backend/sql/gnc-vendor-sql.cpp
@@ -123,7 +123,7 @@ GncSqlVendorBackend::load_all (GncSqlBackend* sql_be)
     auto result = sql_be->execute_select_statement(stmt);
 
     for (auto row : *result)
-        GncVendor* pVendor = load_single_vendor (sql_be, row);
+        load_single_vendor (sql_be, row);
 
     std::string pkey(col_table[0]->name());
     sql = "SELECT DISTINCT ";
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index e3861f5..9b770f2 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -3710,7 +3710,6 @@ xaccAccountCountSplits (const Account *acc, gboolean include_children)
 {
     gint64 nr, i;
 
-    nr = 0;
     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0);
 
     nr = g_list_length(xaccAccountGetSplitList(acc));
diff --git a/libgnucash/engine/ScrubBusiness.c b/libgnucash/engine/ScrubBusiness.c
index cf45c41..60da737 100644
--- a/libgnucash/engine/ScrubBusiness.c
+++ b/libgnucash/engine/ScrubBusiness.c
@@ -151,7 +151,6 @@ scrub_other_link (GNCLot *from_lot, Split *ll_from_split,
     // At this point ll_to_split and real_from_split should have the same value
     // If not, flag a warning and skip to the next iteration
     to_val        = xaccSplitGetValue (ll_to_split);
-    from_val      = xaccSplitGetValue (ll_from_split);
     real_from_val = xaccSplitGetValue (real_from_split);
     if (!gnc_numeric_equal (real_from_val, to_val))
     {
diff --git a/libgnucash/engine/cap-gains.c b/libgnucash/engine/cap-gains.c
index 32122c0..9c73786 100644
--- a/libgnucash/engine/cap-gains.c
+++ b/libgnucash/engine/cap-gains.c
@@ -532,7 +532,7 @@ xaccSplitComputeCapGains(Split *split, Account *gain_acc)
     GNCPolicy *pcy;
     gnc_commodity *currency = NULL;
     gnc_numeric zero = gnc_numeric_zero();
-    gnc_numeric value = zero;
+    gnc_numeric value;
     gnc_numeric frac;
     gnc_numeric opening_amount, opening_value;
     gnc_numeric lot_amount, lot_value;
diff --git a/libgnucash/engine/engine-helpers.c b/libgnucash/engine/engine-helpers.c
index f078c30..51b836d 100644
--- a/libgnucash/engine/engine-helpers.c
+++ b/libgnucash/engine/engine-helpers.c
@@ -769,7 +769,6 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
             is_regex = scm_is_true (scm);
 
             scm = SCM_CAR (qt_scm);
-            qt_scm = SCM_CDR (qt_scm);
             if (!scm_is_string (scm)) break;
 
             matchstring = gnc_scm_to_utf8_string (scm);
@@ -790,7 +789,6 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
             options = gnc_query_scm2date (scm);
 
             scm = SCM_CAR (qt_scm);
-            qt_scm = SCM_CDR (qt_scm);
             if (scm_is_null (scm))
                 break;
             date = scm_to_int64 (scm);
@@ -810,7 +808,6 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
             options = gnc_query_scm2numericop (scm);
 
             scm = SCM_CAR (qt_scm);
-            qt_scm = SCM_CDR (qt_scm);
             if (!gnc_query_numeric_p (scm))
                 break;
             val = gnc_query_scm2numeric (scm);
@@ -830,7 +827,6 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
             options = gnc_query_scm2guid (scm);
 
             scm = SCM_CAR (qt_scm);
-            qt_scm = SCM_CDR (qt_scm);
             if (!scm_is_list (scm))
                 break;
             guids = gnc_scm2guid_glist (scm);
@@ -845,7 +841,6 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
             gint64 val;
 
             scm = SCM_CAR (qt_scm);
-            qt_scm = SCM_CDR (qt_scm);
             if (scm_is_null (scm))
                 break;
             val = scm_to_int64 (scm);
@@ -858,7 +853,6 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
             double val;
 
             scm = SCM_CAR (qt_scm);
-            qt_scm = SCM_CDR (qt_scm);
             if (!scm_is_number (scm))
                 break;
             val = scm_to_double (scm);
@@ -871,7 +865,6 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
             gboolean val;
 
             scm = SCM_CAR (qt_scm);
-            qt_scm = SCM_CDR (qt_scm);
             if (!scm_is_bool (scm))
                 break;
             val = scm_is_true (scm);
@@ -891,7 +884,6 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
             options = gnc_query_scm2char (scm);
 
             scm = SCM_CAR (qt_scm);
-            qt_scm = SCM_CDR (qt_scm);
             if (!scm_is_string (scm))
                 break;
             char_list = gnc_scm_to_utf8_string (scm);
@@ -1014,7 +1006,6 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
                 break;
 
             scm = SCM_CAR (query_term_scm);
-            query_term_scm = SCM_CDR (query_term_scm);
             end = scm_to_int64 (scm);
 
             xaccQueryAddDateMatchTT (q, use_start, start, use_end, end, QOF_QUERY_OR);
@@ -1047,7 +1038,6 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
             if (scm_is_null (query_term_scm))
                 break;
             scm = SCM_CAR (query_term_scm);
-            query_term_scm = SCM_CDR (query_term_scm);
             val = gnc_numeric_create (scm_to_int64(scm_numerator(scm)),
                                       scm_to_int64(scm_denominator(scm)));
 
@@ -1099,7 +1089,6 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
             }
 
             scm = SCM_CAR (query_term_scm);
-            query_term_scm = SCM_CDR (query_term_scm);
 
             account_guids = gnc_scm2guid_glist (scm);
 
@@ -1137,7 +1126,6 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
                 break;
 
             scm = SCM_CAR (query_term_scm);
-            query_term_scm = SCM_CDR (query_term_scm);
             matchstring = gnc_scm_to_utf8_string (scm);
 
             if (!g_strcmp0 (pr_type, "pr-action"))
@@ -1184,7 +1172,6 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
                 break;
 
             scm = SCM_CAR (query_term_scm);
-            query_term_scm = SCM_CDR (query_term_scm);
             how = gnc_scm2cleared_match_how (scm);
 
             xaccQueryAddClearedMatch (q, how, QOF_QUERY_OR);
@@ -1200,7 +1187,6 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
                 break;
 
             scm = SCM_CAR (query_term_scm);
-            query_term_scm = SCM_CDR (query_term_scm);
             if (gnc_scm2balance_match_how (scm, &how) == FALSE)
                 break;
 
@@ -1223,7 +1209,6 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
 
             /* id type */
             scm = SCM_CAR (query_term_scm);
-            query_term_scm = SCM_CDR (query_term_scm);
             id_type = (QofIdType) gnc_scm_to_utf8_string (scm);
 
             xaccQueryAddGUIDMatch (q, &guid, id_type, QOF_QUERY_OR);
diff --git a/libgnucash/engine/gnc-aqbanking-templates.cpp b/libgnucash/engine/gnc-aqbanking-templates.cpp
index 6749d0e..b8a7c7a 100644
--- a/libgnucash/engine/gnc-aqbanking-templates.cpp
+++ b/libgnucash/engine/gnc-aqbanking-templates.cpp
@@ -150,7 +150,6 @@ gnc_ab_trans_templ_list_new_from_book(QofBook *b)
         auto n_func = [frame](const char* key)
             { auto slot = frame->get_slot({key});
               return slot == nullptr ? gnc_numeric_zero() : slot->get<gnc_numeric>();};
-        auto amt_slot = frame->get_slot({TT_AMOUNT});
         auto templ = new _GncABTransTempl (c_func(TT_NAME), c_func(TT_RNAME),
                                            c_func(TT_RACC), c_func(TT_RBCODE),
                                            n_func(TT_AMOUNT), c_func(TT_PURPOS),
diff --git a/libgnucash/engine/gnc-pricedb.c b/libgnucash/engine/gnc-pricedb.c
index 8f462c3..b7efb28 100644
--- a/libgnucash/engine/gnc-pricedb.c
+++ b/libgnucash/engine/gnc-pricedb.c
@@ -1495,7 +1495,6 @@ gnc_pricedb_process_removal_list (GNCPriceDB *db, GDate *fiscal_end_date,
     gboolean save_first_price = FALSE;
     gint saved_test_value = 0, next_test_value = 0;
     GNCPrice *cloned_price = NULL;
-    GDateMonth fiscal_month_end = g_date_get_month (fiscal_end_date);
     GDateMonth fiscal_month_start;
     GDate *tmp_date = g_date_new_dmy (g_date_get_day (fiscal_end_date),
                                       g_date_get_month (fiscal_end_date),
@@ -1527,7 +1526,6 @@ gnc_pricedb_process_removal_list (GNCPriceDB *db, GDate *fiscal_end_date,
         if (save_first_price == TRUE)
         {
             clone_price (&cloned_price, item->data);
-            save_first_price = FALSE;
             continue;
         }
 
diff --git a/libgnucash/engine/gnc-timezone.cpp b/libgnucash/engine/gnc-timezone.cpp
index 275e234..3bb157b 100644
--- a/libgnucash/engine/gnc-timezone.cpp
+++ b/libgnucash/engine/gnc-timezone.cpp
@@ -435,9 +435,6 @@ namespace IANAParser
 	    time_count = *(endian_swap(reinterpret_cast<uint32_t*>(tzh.timecnt)));
 	    type_count = *(endian_swap(reinterpret_cast<uint32_t*>(tzh.typecnt)));
 	    char_count = *(endian_swap(reinterpret_cast<uint32_t*>(tzh.charcnt)));
-	    isgmt_count = *(endian_swap(reinterpret_cast<uint32_t*>(tzh.ttisgmtcnt)));
-	    isstd_count = *(endian_swap(reinterpret_cast<uint32_t*>(tzh.ttisstdcnt)));
-	    leap_count = *(endian_swap(reinterpret_cast<uint32_t*>(tzh.leapcnt)));
 	    transition_size = 8;
 	}
 	fb_index += sizeof(tzh);
diff --git a/libgnucash/engine/gncInvoice.c b/libgnucash/engine/gncInvoice.c
index e725d6a..9ad4869 100644
--- a/libgnucash/engine/gncInvoice.c
+++ b/libgnucash/engine/gncInvoice.c
@@ -953,7 +953,6 @@ gncInvoiceGetTotalInternal(GncInvoice *invoice, gboolean use_value,
 
     if (!invoice) return gnc_numeric_zero();
 
-    denom = gnc_commodity_get_fraction(gncInvoiceGetCurrency(invoice));
     total = gncInvoiceGetNetAndTaxesInternal(invoice, use_value, use_tax? &taxes : NULL, use_payment_type, type);
 
     if (use_tax)
@@ -998,7 +997,7 @@ AccountValueList *gncInvoiceGetTotalTaxList (GncInvoice *invoice)
     AccountValueList *taxes;
     if (!invoice) return NULL;
 
-    unused = gncInvoiceGetNetAndTaxesInternal(invoice, FALSE, &taxes, FALSE, 0);
+    gncInvoiceGetNetAndTaxesInternal(invoice, FALSE, &taxes, FALSE, 0);
     return taxes;
 }
 
diff --git a/libgnucash/engine/qofbook.cpp b/libgnucash/engine/qofbook.cpp
index d306f87..c0cb043 100644
--- a/libgnucash/engine/qofbook.cpp
+++ b/libgnucash/engine/qofbook.cpp
@@ -212,8 +212,7 @@ qof_book_get_property (GObject* object,
         qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {"fy_end"});
         break;
     case PROP_AB_TEMPLATES:
-        key = const_cast<char*>(AB_KEY "/" AB_TEMPLATES);
-        qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {"AB_KEY", "AB_TEMPLATES"});
+          qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {"AB_KEY", "AB_TEMPLATES"});
         break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
diff --git a/libgnucash/engine/qofinstance.cpp b/libgnucash/engine/qofinstance.cpp
index 670f91b..9b3058d 100644
--- a/libgnucash/engine/qofinstance.cpp
+++ b/libgnucash/engine/qofinstance.cpp
@@ -937,7 +937,6 @@ void
 qof_instance_set (QofInstance *inst, const gchar *first_prop, ...)
 {
     va_list ap;
-    QofInstancePrivate *priv = GET_PRIVATE(inst);
     g_return_if_fail (QOF_IS_INSTANCE (inst));
 
     qof_instance_set_dirty (inst);
diff --git a/libgnucash/engine/qofquery.cpp b/libgnucash/engine/qofquery.cpp
index 92c9719..5af8560 100644
--- a/libgnucash/engine/qofquery.cpp
+++ b/libgnucash/engine/qofquery.cpp
@@ -803,7 +803,6 @@ static GList * qof_query_run_internal (QofQuery *q,
             g_list_free(matching_objects);
             matching_objects = NULL;
         }
-        object_count = q->max_results;
     }
 
     q->changed = 0;

commit a93448414f3e790e52a3f627f7f4b6c5df463a98
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Nov 30 13:52:21 2018 +0900

    Fix another uninitialized variable in register.
    
    Found by clang static analyzer.

diff --git a/gnucash/register/ledger-core/gncEntryLedger.c b/gnucash/register/ledger-core/gncEntryLedger.c
index 86b5b31..c979347 100644
--- a/gnucash/register/ledger-core/gncEntryLedger.c
+++ b/gnucash/register/ledger-core/gncEntryLedger.c
@@ -721,7 +721,7 @@ void
 gnc_entry_ledger_compute_value (GncEntryLedger *ledger,
                                 gnc_numeric *value, gnc_numeric *tax_value)
 {
-    gnc_numeric qty, price = gnc_numeric_zero(), discount = gnc_numeric_zero();
+    gnc_numeric qty = gnc_numeric_zero(), price = gnc_numeric_zero(), discount = gnc_numeric_zero();
     gint disc_type, disc_how;
     gboolean taxable, taxincluded;
     GncTaxTable *table;

commit f52609961e43b165f532ebe2d234626ceaa4372f
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Nov 29 21:49:54 2018 +0900

    Fix uninitialized variables (and one leak) in gnome.
    
    Found by clang static analyzer.

diff --git a/gnucash/gnome/dialog-print-check.c b/gnucash/gnome/dialog-print-check.c
index 5fcbe43..95065c7 100644
--- a/gnucash/gnome/dialog-print-check.c
+++ b/gnucash/gnome/dialog-print-check.c
@@ -1414,6 +1414,7 @@ format_read_general_info(const gchar *file,
 static void
 free_check_format(check_format_t *data)
 {
+    g_return_if_fail(data);
     g_free(data->guid);
     g_free(data->filename);
     g_free(data->title);
@@ -1476,7 +1477,7 @@ static void
 read_one_check_directory(PrintCheckDialog *pcd, GtkListStore *store,
                          const gchar *groupname, const gchar *dirname)
 {
-    check_format_t *format, *existing;
+    check_format_t *format = NULL, *existing;
     GDir *dir;
     const gchar *filename;
     GtkTreeIter iter;
diff --git a/gnucash/gnome/dialog-sx-since-last-run.c b/gnucash/gnome/dialog-sx-since-last-run.c
index 0da2f9e..7ed241a 100644
--- a/gnucash/gnome/dialog-sx-since-last-run.c
+++ b/gnucash/gnome/dialog-sx-since-last-run.c
@@ -920,7 +920,7 @@ variable_value_changed_cb(GtkCellRendererText *cell,
                           const gchar *value,
                           GncSxSinceLastRunDialog *dialog)
 {
-    GncSxVariable *var;
+    GncSxVariable *var = NULL;
     GncSxInstance *inst;
     GtkTreeIter tree_iter;
     gnc_numeric parsed_num;
diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index 46f9517..529c4a5 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -548,6 +548,7 @@ gnc_plugin_page_account_tree_open (Account *account, GtkWindow *win)
     else // we have no account pages, create one
         plugin_page = gnc_plugin_page_account_tree_new ();
 
+    g_return_if_fail(plugin_page);
     window = plugin_page->window;
 
     gnc_main_window_open_page (GNC_MAIN_WINDOW(window), plugin_page);
diff --git a/gnucash/gnome/gnc-split-reg2.c b/gnucash/gnome/gnc-split-reg2.c
index cb8a868..edf20f4 100644
--- a/gnucash/gnome/gnc-split-reg2.c
+++ b/gnucash/gnome/gnc-split-reg2.c
@@ -505,7 +505,7 @@ gsr2_redraw_all_cb (GncTreeViewSplitReg *view, gpointer user_data)
     GNCSplitReg2 *gsr = user_data;
     gnc_commodity * commodity;
     GNCPrintAmountInfo print_info;
-    gnc_numeric amount;
+    gnc_numeric amount = gnc_numeric_zero();
     Account *leader;
     gboolean reverse;
     gboolean euro;
@@ -976,6 +976,7 @@ gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr) //this works
         {
         case PLACEHOLDER_NONE:
             /* stay as false. */
+            g_free (args);
             return;
 
         case PLACEHOLDER_THIS:

commit 185787d7be17b4927b4b0396f317ff2cc20e5eea
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 22:24:41 2018 +0900

    Initialize some gnc_numerics that could be returned uninitialized.
    
    Found by clang static analyzer.

diff --git a/gnucash/import-export/csv-imp/gnc-imp-props-price.cpp b/gnucash/import-export/csv-imp/gnc-imp-props-price.cpp
index 874d218..a7a7185 100644
--- a/gnucash/import-export/csv-imp/gnc-imp-props-price.cpp
+++ b/gnucash/import-export/csv-imp/gnc-imp-props-price.cpp
@@ -66,7 +66,7 @@ GncNumeric parse_amount_price (const std::string &str, int currency_format)
     std::string str_no_symbols = boost::u32regex_replace(str, expr, "");
 
     /* Convert based on user chosen currency format */
-    gnc_numeric val;
+    gnc_numeric val = gnc_numeric_zero();
     char *endptr;
     switch (currency_format)
     {
diff --git a/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp b/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp
index 25ec7b7..4df6001 100644
--- a/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp
+++ b/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp
@@ -114,7 +114,7 @@ GncNumeric parse_amount (const std::string &str, int currency_format)
     std::string str_no_symbols = boost::u32regex_replace(str, expr, "");
 
     /* Convert based on user chosen currency format */
-    gnc_numeric val;
+    gnc_numeric val = gnc_numeric_zero();
     char *endptr;
     switch (currency_format)
     {
diff --git a/gnucash/register/ledger-core/gncEntryLedger.c b/gnucash/register/ledger-core/gncEntryLedger.c
index 8bf2d19..86b5b31 100644
--- a/gnucash/register/ledger-core/gncEntryLedger.c
+++ b/gnucash/register/ledger-core/gncEntryLedger.c
@@ -721,7 +721,7 @@ void
 gnc_entry_ledger_compute_value (GncEntryLedger *ledger,
                                 gnc_numeric *value, gnc_numeric *tax_value)
 {
-    gnc_numeric qty, price, discount;
+    gnc_numeric qty, price = gnc_numeric_zero(), discount = gnc_numeric_zero();
     gint disc_type, disc_how;
     gboolean taxable, taxincluded;
     GncTaxTable *table;
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index 34f887a..bc83f09 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -597,7 +597,7 @@ gnc_split_register_use_negative_color (VirtualLocation virt_loc,
                                        SplitRegister *reg)
 {
     const char * cell_name;
-    gnc_numeric value;
+    gnc_numeric value = gnc_numeric_zero();
     Split *split;
 
     if (!use_red_for_negative)

commit 8ed9a9c43af638276343dd886daea958079ef768
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 22:22:28 2018 +0900

    Initialize some variables that could be otherwise used uninitialized.
    
    Found by clang static analyzer.

diff --git a/gnucash/register/register-gnome/gnucash-cursor.c b/gnucash/register/register-gnome/gnucash-cursor.c
index fdb860c..cc93cce 100644
--- a/gnucash/register/register-gnome/gnucash-cursor.c
+++ b/gnucash/register/register-gnome/gnucash-cursor.c
@@ -131,7 +131,7 @@ gnucash_cursor_get_virt (GnucashCursor *cursor, VirtualLocation *virt_loc)
 void
 gnucash_cursor_configure (GnucashCursor *cursor)
 {
-    gint x, y, w, h;
+    gint x = 0, y = 0, w = 0, h = 0;
 
     g_return_if_fail (cursor != NULL);
     g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index f4cabb7..fc5d7b3 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -111,7 +111,7 @@ gnc_item_edit_tb_get_preferred_width (GtkWidget *widget,
 {
     GncItemEditTb *tb = GNC_ITEM_EDIT_TB (widget);
     GncItemEdit *item_edit = GNC_ITEM_EDIT(tb->sheet->item_editor);
-    gint x, y, w, h, width = 0;
+    gint x, y, w, h = 2, width = 0;
     gnc_item_edit_get_pixel_coords (GNC_ITEM_EDIT (item_edit), &x, &y, &w, &h);
     width = ((h - 2)*2)/3;
     if (width < 20) // minimum size for a button
@@ -126,7 +126,7 @@ gnc_item_edit_tb_get_preferred_height (GtkWidget *widget,
 {
     GncItemEditTb *tb = GNC_ITEM_EDIT_TB (widget);
     GncItemEdit *item_edit = GNC_ITEM_EDIT(tb->sheet->item_editor);
-    gint x, y, w, h;
+    gint x, y, w, h = 2;
     gnc_item_edit_get_pixel_coords (GNC_ITEM_EDIT (item_edit), &x, &y, &w, &h);
     *minimal_width = *natural_width = (h - 2);
 }
@@ -246,7 +246,7 @@ gnc_item_edit_get_pixel_coords (GncItemEdit *item_edit,
 static gboolean
 gnc_item_edit_update (GncItemEdit *item_edit)
 {
-    gint x, y, w, h;
+    gint x = 0, y = 0, w, h;
 
     gnc_item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h);
     gtk_layout_move (GTK_LAYOUT(item_edit->sheet),
@@ -670,7 +670,7 @@ gnc_item_edit_get_preferred_width (GtkWidget *widget,
                                    gint *minimal_width,
                                    gint *natural_width)
 {
-    gint x, y, w, h;
+    gint x, y, w = 1, h;
     gnc_item_edit_get_pixel_coords (GNC_ITEM_EDIT (widget), &x, &y, &w, &h);
     *minimal_width = *natural_width = w - 1;
 }
@@ -681,7 +681,7 @@ gnc_item_edit_get_preferred_height (GtkWidget *widget,
                                     gint *minimal_width,
                                     gint *natural_width)
 {
-    gint x, y, w, h;
+    gint x, y, w, h = 1;
     gnc_item_edit_get_pixel_coords (GNC_ITEM_EDIT (widget), &x, &y, &w, &h);
     *minimal_width = *natural_width = h - 1;
 }
@@ -934,7 +934,7 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
     GtkAdjustment *vadj, *hadj;
     GtkAllocation alloc;
     GnucashSheet *sheet;
-    gint x, y, w, h;
+    gint x = 0, y = 0, w = 0, h = 0;
     gint y_offset, x_offset;
     gint popup_x, popup_y;
     gint popup_w = -1, popup_h = -1;
diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c
index aa13c55..808c2a2 100644
--- a/gnucash/register/register-gnome/gnucash-sheet-private.c
+++ b/gnucash/register/register-gnome/gnucash-sheet-private.c
@@ -603,7 +603,7 @@ gboolean
 gnucash_sheet_draw_internal (GnucashSheet* sheet, cairo_t* cr,
                              GtkAllocation* alloc)
 {
-    VirtualLocation virt_loc;
+    VirtualLocation virt_loc = {{0, 0}, 0, 0};
     SheetBlock *sheet_block;
     int x = 0;
     int y = 0;
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 25e6c7d..38811b2 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -2410,7 +2410,7 @@ gnucash_sheet_recompute_block_offsets (GnucashSheet *sheet)
                 width += block->style->dimensions->width;
         }
 
-        if (i > 0 && block->visible)
+        if (i > 0 && block && block->visible)
             height += block->style->dimensions->height;
     }
 

commit 7e10b05c494f262ca7c31fd8c8bc54d61a8fed98
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 22:07:01 2018 +0900

    Avoid over-ranging string storage.
    
    Found by clang static analyzer.

diff --git a/gnucash/import-export/import-account-matcher.c b/gnucash/import-export/import-account-matcher.c
index 36fb7c6..6ee4e90 100644
--- a/gnucash/import-export/import-account-matcher.c
+++ b/gnucash/import-export/import-account-matcher.c
@@ -248,7 +248,7 @@ Account * gnc_import_select_account(GtkWidget *parent,
     const gchar *retval_name = NULL;
     GtkBuilder *builder;
     GtkWidget * online_id_label, *box, *pbox;
-    gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE] = "";
+    gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE + 1] = "";
     gboolean ok_pressed_retval = FALSE;
 
     ENTER("Default commodity received: %s", gnc_commodity_get_fullname( new_account_default_commodity));
@@ -496,7 +496,7 @@ Account * gnc_import_account_assist_update (AccountPickerDialog *picker)
 #define ACCOUNT_DESCRIPTION_MAX_SIZE 255
 
     const gchar *retval_name = NULL;
-    gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE] = "";
+    gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE + 1] = "";
 
     ENTER("Default commodity received: %s", gnc_commodity_get_fullname( picker->new_account_default_commodity));
     DEBUG("Default account type received: %s", xaccAccountGetTypeStr( picker->new_account_default_type));

commit 7283c86f6f0a20cd9bdbe7587273c2b625026cce
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 21:58:05 2018 +0900

    Fix various static analysis logic errors in gnome-utils.

diff --git a/gnucash/gnome-utils/assistant-xml-encoding.c b/gnucash/gnome-utils/assistant-xml-encoding.c
index 0e04e23..11cebad 100644
--- a/gnucash/gnome-utils/assistant-xml-encoding.c
+++ b/gnucash/gnome-utils/assistant-xml-encoding.c
@@ -1266,7 +1266,7 @@ gxi_edit_encodings_clicked_cb (GtkButton *button, GncXmlImportData *data)
     if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
     {
         g_list_free (encodings_bak);
-        if (!g_list_find (data->encodings,
+        if (data->encodings && !g_list_find (data->encodings,
                           GUINT_TO_POINTER (data->default_encoding)))
         {
             /* choose top level encoding then */
diff --git a/gnucash/gnome-utils/dialog-preferences.c b/gnucash/gnome-utils/dialog-preferences.c
index 42acab2..49bd5e7 100644
--- a/gnucash/gnome-utils/dialog-preferences.c
+++ b/gnucash/gnome-utils/dialog-preferences.c
@@ -561,7 +561,7 @@ gnc_preferences_build_page (gpointer data,
     GtkWidget *dialog, *existing_content, *new_content, *label;
     GtkNotebook *notebook;
     addition *add_in;
-    struct copy_data copydata;
+    struct copy_data copydata = {NULL, NULL, 0, 0};
     gchar **widgetname;
     gint i;
 
diff --git a/gnucash/gnome-utils/dialog-totd.c b/gnucash/gnome-utils/dialog-totd.c
index ac79108..4c5e599 100644
--- a/gnucash/gnome-utils/dialog-totd.c
+++ b/gnucash/gnome-utils/dialog-totd.c
@@ -102,11 +102,11 @@ gnc_new_tip_number (TotdDialog *totd_dialog, gint offset)
      *  Welcome to GnuCash version %s|2.4
      */
     if (tip_list[current_tip_number])
-	tip_components = g_strsplit(tip_list[current_tip_number], "|", 0);
+        tip_components = g_strsplit(tip_list[current_tip_number], "|", 0);
     /* If the tip is empty, g_strisplit will return an empty list. This
      * shouldn't normally happen, but make sure we don't crash just in
      * case */
-    if (tip_components[0] == NULL)
+    if (tip_components == NULL)
     {
         tip = g_strdup("");
     }
diff --git a/gnucash/gnome-utils/gnc-cell-renderer-date.c b/gnucash/gnome-utils/gnc-cell-renderer-date.c
index e47a386..91e422f 100644
--- a/gnucash/gnome-utils/gnc-cell-renderer-date.c
+++ b/gnucash/gnome-utils/gnc-cell-renderer-date.c
@@ -308,9 +308,9 @@ gcrd_show (GncCellRendererPopup *cell,
 	   gint                      y2)
 {
 	GncCellRendererDate     *date;
-	gint                     year;
-	gint                     month;
-	gint                     day;
+	gint                     year = 0;
+	gint                     month = 0;
+	gint                     day = 0;
 	const gchar             *text;
 
 	if (parent_class->show_popup) {
@@ -358,7 +358,7 @@ static void
 gcrd_today_clicked (GtkWidget *button, GncCellRendererDate *cell)
 {
 	time64  today;
-	gint    year, month, day;
+	gint    year = 0, month = 0, day = 0;
 	
 	today = gnc_time (NULL);
 
diff --git a/gnucash/gnome-utils/gnc-date-edit.c b/gnucash/gnome-utils/gnc-date-edit.c
index b729c33..547c121 100644
--- a/gnucash/gnome-utils/gnc-date-edit.c
+++ b/gnucash/gnome-utils/gnc-date-edit.c
@@ -126,7 +126,7 @@ gnc_strtok_r (char *s, const char *delim, char **save_ptr)
 
     /* Scan leading delimiters.  */
     s += strspn (s, delim);
-    if (*s == '\0')
+    if (!s || *s == '\0')
         return NULL;
 
     /* Find the end of the token.  */
diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index fb86d24..1ba3b40 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -768,7 +768,7 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da
              (pos[1] > gdk_screen_height()))
     {
         g_debug("position %dx%d, size%dx%d is offscreen; will not move",
-                pos[0], pos[1], geom[0], geom[1]);
+                pos[0], pos[1], geom ? geom[0] : 0, geom ? geom[1] : 0);
     }
     else
     {
@@ -1653,7 +1653,7 @@ static gchar *generate_statusbar_lastmodified_message()
         book_id = qof_session_get_url (gnc_get_current_session ());
     }
 
-    if (!strlen (book_id))
+    if (!(book_id && strlen (book_id)))
         return NULL;
     else
     {
diff --git a/gnucash/gnome-utils/gnc-query-view.c b/gnucash/gnome-utils/gnc-query-view.c
index 7ba8df8..8830aa3 100644
--- a/gnucash/gnome-utils/gnc-query-view.c
+++ b/gnucash/gnome-utils/gnc-query-view.c
@@ -822,7 +822,7 @@ gnc_query_view_fill (GNCQueryView *qview)
             }
 
             /* Now convert this to a text value for the row */
-            if ( g_strcmp0(type, QOF_TYPE_DEBCRED) == 0 || g_strcmp0(type, QOF_TYPE_NUMERIC) == 0 )
+            if (qp && (g_strcmp0(type, QOF_TYPE_DEBCRED) == 0 || g_strcmp0(type, QOF_TYPE_NUMERIC) == 0))
             {
 
                 gnc_numeric (*nfcn)(gpointer, QofParam *) =
diff --git a/gnucash/gnome-utils/gnc-tree-model-split-reg.c b/gnucash/gnome-utils/gnc-tree-model-split-reg.c
index e44fd76..4688f5c 100644
--- a/gnucash/gnome-utils/gnc-tree-model-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-model-split-reg.c
@@ -1337,7 +1337,7 @@ gnc_tree_model_split_reg_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
        This path should be freed with gtk_tree_path_free(). */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
     GtkTreePath *path;
-    gint tpos, spos;
+    gint tpos = -1, spos = -1;
     GList *tnode, *snode;
 
     g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model), NULL);
@@ -1371,7 +1371,7 @@ gnc_tree_model_split_reg_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
         {
             spos = xaccTransCountSplits (tnode->data);
         }
-        else
+        else if (tnode && snode)
         {
             /* Can not use snode position directly as slist length does not follow
                number of splits exactly, especailly if you delete a split */
diff --git a/gnucash/gnome-utils/gnc-tree-view-account.c b/gnucash/gnome-utils/gnc-tree-view-account.c
index 0d0d64b..2953cd1 100644
--- a/gnucash/gnome-utils/gnc-tree-view-account.c
+++ b/gnucash/gnome-utils/gnc-tree-view-account.c
@@ -2591,14 +2591,15 @@ gtva_set_column_editor(GncTreeViewAccount *view,
                        GncTreeViewAccountColumnTextEdited edited_cb)
 {
     GList *renderers_orig, *renderers;
-    GtkCellRenderer *renderer;
+    GtkCellRenderer *renderer = NULL;
 
     // look for the first text-renderer; on the 0th column of the account tree,
     // there are two renderers: pixbuf and text.  So find the text one.
     for (renderers_orig = renderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
             renderers && !GTK_IS_CELL_RENDERER_TEXT(renderers->data);
             renderers = renderers->next);
-    renderer = GTK_CELL_RENDERER(renderers->data);
+    if (renderers)
+        renderer = GTK_CELL_RENDERER(renderers->data);
     g_list_free(renderers_orig);
     g_return_if_fail(renderer != NULL);
     gtva_setup_column_renderer_edited_cb(GNC_TREE_VIEW_ACCOUNT(view), column, renderer, edited_cb);

commit 876bfd19ad2c7d80d8dae008241c9ef67f1655a2
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 16:18:34 2018 +0900

    Protect against nullptr dereference, remove unused GError.
    
    Found by clang static analyzer.

diff --git a/libgnucash/backend/xml/io-gncxml-v2.cpp b/libgnucash/backend/xml/io-gncxml-v2.cpp
index 3c04094..3b2c0b3 100644
--- a/libgnucash/backend/xml/io-gncxml-v2.cpp
+++ b/libgnucash/backend/xml/io-gncxml-v2.cpp
@@ -1539,7 +1539,6 @@ try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
     {
         int filedes[2];
         GThread* thread;
-        GError* error = NULL;
         gz_thread_params_t* params;
         FILE* file;
 
@@ -1564,9 +1563,7 @@ try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
                                params);
         if (!thread)
         {
-            g_warning ("Could not create thread for (de)compression: %s",
-                       error->message);
-            g_error_free (error);
+            g_warning ("Could not create thread for (de)compression.");
             g_free (params->filename);
             g_free (params->perms);
             g_free (params);
diff --git a/libgnucash/backend/xml/io-utils.cpp b/libgnucash/backend/xml/io-utils.cpp
index 733956f..c2d033e 100644
--- a/libgnucash/backend/xml/io-utils.cpp
+++ b/libgnucash/backend/xml/io-utils.cpp
@@ -65,6 +65,8 @@ write_one_account (FILE* out,
     xmlElemDump (out, NULL, accnode);
     xmlFreeNode (accnode);
 
+    g_return_val_if_fail(gd, FALSE);
+    
     if (ferror (out) || fprintf (out, "\n") < 0)
         return FALSE;
 

commit 24ce92056ddf5f6137827467634ddb1ef7e2bc75
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 16:11:32 2018 +0900

    Protect from potential nullptr dereferences.
    
    pmtsched is created in only one banch of the opening switch.
    Found by clang static analyzer.

diff --git a/libgnucash/app-utils/calculation/fin.c b/libgnucash/app-utils/calculation/fin.c
index 37bb185..a0235ff 100644
--- a/libgnucash/app-utils/calculation/fin.c
+++ b/libgnucash/app-utils/calculation/fin.c
@@ -1969,13 +1969,16 @@ Amortization_Schedule (amort_sched_ptr amortsched)
             /* and set remaining pv to fv */
             pv = fv;
 
-            pmtsched->period_num = s++;
-            pmtsched->interest = pmt_int;
-            pmtsched->principal = prin;
-            pmtsched->advanced_pmt = adv_pmt;
-            pmtsched->total_pmt = final_pmt;
-            pmtsched->balance = pv;
-
+            if (pmtsched)
+            {
+                pmtsched->period_num = s++;
+                pmtsched->interest = pmt_int;
+                pmtsched->principal = prin;
+                pmtsched->advanced_pmt = adv_pmt;
+                pmtsched->total_pmt = final_pmt;
+                pmtsched->balance = pv;
+            }
+            
             per_cnt++;
             pmt_cnt++;
         }				/* endif */
@@ -2111,13 +2114,16 @@ Amortization_Schedule (amort_sched_ptr amortsched)
             /* # and set remaining pv to fv */
             pv = fv;
 
-            pmtsched->period_num = s++;
-            pmtsched->interest = pmt_int;
-            pmtsched->principal = prin;
-            pmtsched->advanced_pmt = adv_pmt;
-            pmtsched->total_pmt = final_pmt;
-            pmtsched->balance = pv;
-
+            if (pmtsched)
+            {
+                pmtsched->period_num = s++;
+                pmtsched->interest = pmt_int;
+                pmtsched->principal = prin;
+                pmtsched->advanced_pmt = adv_pmt;
+                pmtsched->total_pmt = final_pmt;
+                pmtsched->balance = pv;
+            }
+            
             per_cnt++;
             pmt_cnt++;
         }				/* # endif */
@@ -2199,12 +2205,14 @@ Amortization_Schedule (amort_sched_ptr amortsched)
 
             /* sum total interest paid */
             sum_int += pmt_int;
-
-            pmtsched->period_num = s++;
-            pmtsched->interest = -pmt_int;
-            pmtsched->total_pmt = -pv + pmt_int;
-            pmtsched->balance = 0.0;
-
+            if (pmtsched)
+            {
+                pmtsched->period_num = s++;
+                pmtsched->interest = -pmt_int;
+                pmtsched->total_pmt = -pv + pmt_int;
+                pmtsched->balance = 0.0;
+            }
+            
             amortyr->final_pmt = -pv - pmt_int;
         }				/* endif */
 

commit 8f22c4bed4a3da692cbfb042d5b671cd80fb00ec
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 15:41:45 2018 +0900

    Localize variables, ensure that val_imbalance is set, test txn_curr != commodity once.
    
    Found by clang static analyzer.

diff --git a/libgnucash/engine/Scrub.c b/libgnucash/engine/Scrub.c
index 9f93b8d..d6ff107 100644
--- a/libgnucash/engine/Scrub.c
+++ b/libgnucash/engine/Scrub.c
@@ -683,7 +683,6 @@ gnc_transaction_balance_trading (Transaction *trans, Account *root)
         gnc_monetary *imbal_mon = imbalance_commod->data;
         gnc_commodity *commodity;
         gnc_numeric old_amount, new_amount;
-        gnc_numeric old_value, new_value, val_imbalance;
         const gnc_commodity *txn_curr = xaccTransGetCurrency (trans);
 
         commodity = gnc_monetary_commodity (*imbal_mon);
@@ -697,11 +696,6 @@ gnc_transaction_balance_trading (Transaction *trans, Account *root)
             return;
         }
 
-        if (! gnc_commodity_equal (txn_curr, commodity))
-        {
-            val_imbalance = gnc_transaction_get_commodity_imbalance (trans, commodity);
-        }
-
         xaccTransBeginEdit (trans);
 
         old_amount = xaccSplitGetAmount (balance_split);
@@ -719,8 +713,10 @@ gnc_transaction_balance_trading (Transaction *trans, Account *root)
         }
         else
         {
-            old_value = xaccSplitGetValue (balance_split);
-            new_value = gnc_numeric_sub (old_value, val_imbalance,
+            gnc_numeric val_imbalance = gnc_transaction_get_commodity_imbalance (trans,            commodity);
+
+            gnc_numeric old_value = xaccSplitGetValue (balance_split);
+            gnc_numeric new_value = gnc_numeric_sub (old_value, val_imbalance,
                                          gnc_commodity_get_fraction(txn_curr),
                                          GNC_HOW_RND_ROUND_HALF_UP);
 

commit 4ffeb3efac85cd1650f33fb4acd0665936307213
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 15:40:21 2018 +0900

    Ensure that a dereferenced variable isn't NULL.
    
    Found by clang static analyzer.

diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index 355ccb0..866fc1f 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -1752,7 +1752,7 @@ xaccTransRollbackEdit (Transaction *trans)
         if (!qof_instance_is_dirty(QOF_INSTANCE(s)))
             continue;
 
-        if (i < num_preexist)
+        if (i < num_preexist && onode)
         {
             Split *so = onode->data;
 
diff --git a/libgnucash/engine/qofquery.cpp b/libgnucash/engine/qofquery.cpp
index f91d204..92c9719 100644
--- a/libgnucash/engine/qofquery.cpp
+++ b/libgnucash/engine/qofquery.cpp
@@ -486,7 +486,7 @@ compile_sort (QofQuerySort *sort, QofIdType obj)
     /* If we have valid parameters, grab the compare function,
      * If not, check if this is the default sort.
      */
-    if (sort->param_fcns)
+    if (sort->param_fcns && resObj)
     {
         /* First, check if this parameter has a sort function override.
          * if not then check if there's a global compare function for the type
@@ -535,7 +535,7 @@ static void compile_terms (QofQuery *q)
              * If not, see if this is the default sort.
              */
 
-            if (qt->param_fcns)
+            if (qt->param_fcns && resObj)
                 qt->pred_fcn = qof_query_core_get_predicate (resObj->param_type);
             else
                 qt->pred_fcn = NULL;

commit 43a30e1c9799fba2c926f59d488fdfbcd9f6ff54
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 15:39:07 2018 +0900

    Silence clang static analyzer complaint about potential div by 0.
    
    It can't, because if b is 0 the function would have
    returned already; since b.m_hi is 0 b.m_lo can't be. The assert
    reassures clang that this is the case.

diff --git a/libgnucash/engine/gnc-int128.cpp b/libgnucash/engine/gnc-int128.cpp
index d4c25be..e545649 100644
--- a/libgnucash/engine/gnc-int128.cpp
+++ b/libgnucash/engine/gnc-int128.cpp
@@ -770,6 +770,7 @@ GncInt128::div (const GncInt128& b, GncInt128& q, GncInt128& r) const noexcept
     q.m_hi = set_flags(hi, qflags);
     if (hi == 0 && bhi == 0) //let the hardware do it
     {
+        assert (b.m_lo != 0); // b.m_hi is 0 but b isn't or we didn't get here.
         q.m_lo = m_lo / b.m_lo;
         r.m_lo = m_lo % b.m_lo;
         return;

commit 3d1362757be1c8ac73f2f7937ac0dcd696ca6f46
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 15:37:25 2018 +0900

    Prevent potential undefined behavior by shifting by a wrapped uint.
    
    Found by clang static analyzer.

diff --git a/libgnucash/engine/gnc-int128.cpp b/libgnucash/engine/gnc-int128.cpp
index 3da9a9f..d4c25be 100644
--- a/libgnucash/engine/gnc-int128.cpp
+++ b/libgnucash/engine/gnc-int128.cpp
@@ -374,6 +374,8 @@ GncInt128&
 GncInt128::operator<<= (unsigned int i) noexcept
 {
     auto flags = get_flags(m_hi);
+    if (i == 0)
+        return *this;
     if (i > maxbits)
     {
         flags &= 0xfe;

commit 606d9cfee6d64c3ae9ee3d9bed6532e98b4b1a37
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 15:36:06 2018 +0900

    Prevent potential nullptr dereference.
    
    Found by clang static analyzer.

diff --git a/libgnucash/engine/gncCustomer.c b/libgnucash/engine/gncCustomer.c
index 6260b6c..18192d2 100644
--- a/libgnucash/engine/gncCustomer.c
+++ b/libgnucash/engine/gncCustomer.c
@@ -987,10 +987,13 @@ gncCustomerGetCachedBalance (GncCustomer *cust)
 
 void gncCustomerSetCachedBalance (GncCustomer *cust, const gnc_numeric *new_bal)
 {
-    if (!new_bal && cust->balance)
+    if (!new_bal)
     {
-        g_free (cust->balance);
-        cust->balance = NULL;
+        if (cust->balance)
+        {
+            g_free (cust->balance);
+            cust->balance = NULL;
+        }
         return;
     }
 
diff --git a/libgnucash/engine/gncEmployee.c b/libgnucash/engine/gncEmployee.c
index d398a30..8f57494 100644
--- a/libgnucash/engine/gncEmployee.c
+++ b/libgnucash/engine/gncEmployee.c
@@ -962,10 +962,13 @@ gncEmployeeGetCachedBalance (GncEmployee *empl)
 
 void gncEmployeeSetCachedBalance (GncEmployee *empl, const gnc_numeric *new_bal)
 {
-    if (!new_bal && empl->balance)
+    if (!new_bal)
     {
-        g_free (empl->balance);
-        empl->balance = NULL;
+        if (empl->balance)
+        {
+            g_free (empl->balance);
+            empl->balance = NULL;
+        }
         return;
     }
 
diff --git a/libgnucash/engine/gncVendor.c b/libgnucash/engine/gncVendor.c
index 19f75dd..5f01a03 100644
--- a/libgnucash/engine/gncVendor.c
+++ b/libgnucash/engine/gncVendor.c
@@ -1040,10 +1040,13 @@ gncVendorGetCachedBalance (GncVendor *vend)
 
 void gncVendorSetCachedBalance (GncVendor *vend, const gnc_numeric *new_bal)
 {
-    if (!new_bal && vend->balance)
+    if (!new_bal)
     {
-        g_free (vend->balance);
-        vend->balance = NULL;
+        if (vend->balance)
+        {
+            g_free (vend->balance);
+            vend->balance = NULL;
+        }
         return;
     }
 

commit faba7975aca2647792139ed61ca2aabfc1b707a6
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Nov 28 14:48:42 2018 +0900

    Fix a bunch of memory allocation errors found by clang static analysis.

diff --git a/gnucash/gnome-utils/dialog-reset-warnings.c b/gnucash/gnome-utils/dialog-reset-warnings.c
index 02dd18c..c6b0602 100644
--- a/gnucash/gnome-utils/dialog-reset-warnings.c
+++ b/gnucash/gnome-utils/dialog-reset-warnings.c
@@ -366,8 +366,6 @@ gnc_reset_warnings_dialog (GtkWindow *parent)
     GtkWidget  *dialog;
     GtkBuilder *builder;
 
-    rw_dialog = g_new0 (RWDialog, 1);
-
     ENTER("");
     if (gnc_forall_gui_components(DIALOG_RESET_WARNINGS_CM_CLASS,
                                   show_handler, NULL))
@@ -386,6 +384,7 @@ gnc_reset_warnings_dialog (GtkWindow *parent)
 
     gtk_window_set_transient_for(GTK_WINDOW (dialog), parent);
 
+    rw_dialog = g_new0 (RWDialog, 1);
     rw_dialog->dialog = dialog;
     PINFO("rw_dialog %p, dialog %p", rw_dialog, dialog);
 
diff --git a/gnucash/gnome-utils/dialog-totd.c b/gnucash/gnome-utils/dialog-totd.c
index d7158b0..ac79108 100644
--- a/gnucash/gnome-utils/dialog-totd.c
+++ b/gnucash/gnome-utils/dialog-totd.c
@@ -315,8 +315,6 @@ gnc_totd_dialog (GtkWindow *parent, gboolean startup)
     GtkTextView *textview;
     gboolean show_tips;
 
-    totd_dialog = g_new0 (TotdDialog, 1);
-
     show_tips = gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_SHOW_TIPS);
     if (startup && !show_tips)
         return;
@@ -350,6 +348,7 @@ gnc_totd_dialog (GtkWindow *parent, gboolean startup)
     // Set the style context for this dialog so it can be easily manipulated with css
     gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncTotdDialog");
 
+    totd_dialog = g_new0 (TotdDialog, 1);
     totd_dialog->dialog = dialog;
 
     ENTER("totd_dialog %p, dialog %p", totd_dialog, dialog);
diff --git a/gnucash/gnome-utils/gnc-tree-view-split-reg.c b/gnucash/gnome-utils/gnc-tree-view-split-reg.c
index d6fc079..121a43b 100644
--- a/gnucash/gnome-utils/gnc-tree-view-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-view-split-reg.c
@@ -4996,7 +4996,7 @@ gtv_sr_num_cb (GtkEntry    *entry,
         snprintf (buff, sizeof(buff), "%ld", number);
 
         if (g_strcmp0 (buff, "") == 0)
-            leave_string = "";
+            leave_string = g_strdup ("");
         else
             leave_string = g_strdup (buff);
     }
diff --git a/gnucash/gnome/assistant-loan.cpp b/gnucash/gnome/assistant-loan.cpp
index 00af266..3509b18 100644
--- a/gnucash/gnome/assistant-loan.cpp
+++ b/gnucash/gnome/assistant-loan.cpp
@@ -2017,7 +2017,7 @@ void
 loan_rev_hash_to_list( gpointer key, gpointer val, gpointer user_data )
 {
     GList **l = (GList**)user_data;
-    RevRepaymentRow *rrr = g_new0( RevRepaymentRow, 1 );
+    RevRepaymentRow *rrr;
     if ( !key || !val )
     {
         DEBUG( "%.8x, %.8x",
@@ -2025,6 +2025,7 @@ loan_rev_hash_to_list( gpointer key, gpointer val, gpointer user_data )
                GPOINTER_TO_UINT(val));
         return;
     }
+    rrr  = g_new0( RevRepaymentRow, 1 );
     rrr->date = *(GDate*)key;
     rrr->numCells = (gnc_numeric*)val;
     *l = g_list_append( *l, (gpointer)rrr );
diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index adb7e26..49094da 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -2187,6 +2187,7 @@ gnc_invoice_recreate_page (GncMainWindow *window,
         goto give_up;
     }
     g_free(tmp_string);
+    tmp_string = NULL;
 
     /* Get Owner Type */
     owner_type = g_key_file_get_string(key_file, group_name,
diff --git a/gnucash/gnome/dialog-print-check.c b/gnucash/gnome/dialog-print-check.c
index d6f8ad0..5fcbe43 100644
--- a/gnucash/gnome/dialog-print-check.c
+++ b/gnucash/gnome/dialog-print-check.c
@@ -1529,6 +1529,7 @@ read_one_check_directory(PrintCheckDialog *pcd, GtkListStore *store,
             found = TRUE;
         }
     }
+    free_check_format (format);
     g_dir_close(dir);
 
     /* If any files were added to the list, add a separator between
diff --git a/gnucash/gnome/dialog-sx-from-trans.c b/gnucash/gnome/dialog-sx-from-trans.c
index c8625be..19f265f 100644
--- a/gnucash/gnome/dialog-sx-from-trans.c
+++ b/gnucash/gnome/dialog-sx-from-trans.c
@@ -789,7 +789,7 @@ gnc_sx_create_from_trans( GtkWindow *parent, Transaction *trans )
                                  "from a Transaction currently "
                                  "being edited. Please Enter the "
                                  "Transaction before Scheduling." ) );
-            sxftd_close( sxfti, TRUE );
+            sxftd_destroy (NULL, sxfti);
             return;
         }
         else
diff --git a/gnucash/gnome/gnc-split-reg.c b/gnucash/gnome/gnc-split-reg.c
index 589564d..56b1257 100644
--- a/gnucash/gnome/gnc-split-reg.c
+++ b/gnucash/gnome/gnc-split-reg.c
@@ -2285,7 +2285,6 @@ static
 void
 gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
 {
-    dialog_args *args = g_malloc(sizeof(dialog_args));
     SplitRegister *reg;
 
     if (qof_book_is_readonly(gnc_get_current_book()))
@@ -2297,7 +2296,8 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
 
     if ( !gsr->read_only )
     {
-
+        dialog_args *args;
+        char *string = NULL;
         switch (gnc_split_reg_get_placeholder(gsr))
         {
         case PLACEHOLDER_NONE:
@@ -2305,14 +2305,14 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
             return;
 
         case PLACEHOLDER_THIS:
-            args->string = _("This account may not be edited. If you want "
+            string = _("This account may not be edited. If you want "
                              "to edit transactions in this register, please "
                              "open the account options and turn off the "
                              "placeholder checkbox.");
             break;
 
         default:
-            args->string = _("One of the sub-accounts selected may not be "
+            string = _("One of the sub-accounts selected may not be "
                              "edited. If you want to edit transactions in "
                              "this register, please open the sub-account "
                              "options and turn off the placeholder checkbox. "
@@ -2322,6 +2322,8 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
         }
         gsr->read_only = TRUE;
         /* Put up a warning dialog */
+        args = g_malloc(sizeof(dialog_args));
+        args->string = string;
         args->gsr = gsr;
         g_timeout_add (250, gtk_callback_bug_workaround, args); /* 0.25 seconds */
     }
diff --git a/gnucash/gnome/gnc-split-reg2.c b/gnucash/gnome/gnc-split-reg2.c
index 1c45682..cb8a868 100644
--- a/gnucash/gnome/gnc-split-reg2.c
+++ b/gnucash/gnome/gnc-split-reg2.c
@@ -911,7 +911,7 @@ gsr2_determine_account_pr_dialog (gpointer argp)
 static void
 gnc_split_reg2_determine_account_pr (GNCSplitReg2 *gsr)
 {
-    dialog_args *args = g_malloc (sizeof (dialog_args));
+    dialog_args *args;
     GncTreeModelSplitReg *model;
 
     model = gnc_ledger_display2_get_split_model_register (gsr->ledger);
@@ -920,6 +920,8 @@ gnc_split_reg2_determine_account_pr (GNCSplitReg2 *gsr)
         return;
 
     /* Put up a warning dialog */
+    args  = g_malloc (sizeof (dialog_args));
+    args->string = _(""); /* FIXME: No string for dialog. */
     args->gsr = gsr;
     g_timeout_add (250, gsr2_determine_account_pr_dialog, args); /* 0.25 seconds */
 }
@@ -958,7 +960,6 @@ static
 void
 gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr) //this works
 {
-    dialog_args *args = g_malloc (sizeof (dialog_args));
 
     if (qof_book_is_readonly (gnc_get_current_book()))
     {
@@ -969,6 +970,7 @@ gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr) //this works
 
     if (!gsr->read_only)
     {
+        dialog_args *args = g_malloc (sizeof (dialog_args));
 
         switch (gnc_split_reg2_get_placeholder (gsr))
         {
diff --git a/gnucash/gnucash-bin.c b/gnucash/gnucash-bin.c
index d4e1eb6..bff1f40 100644
--- a/gnucash/gnucash-bin.c
+++ b/gnucash/gnucash-bin.c
@@ -173,29 +173,32 @@ static void
 mac_set_currency_locale(NSLocale *locale, NSString *locale_str)
 {
     /* If the currency doesn't match the base locale, we need to find a locale that does match, because setlocale won't know what to do with just a currency identifier. */
+    NSLocale *cur_locale = [[NSLocale alloc] initWithLocaleIdentifier: locale_str];
     if (![[locale objectForKey: NSLocaleCurrencyCode] isEqualToString:
-	  [[[NSLocale alloc] initWithLocaleIdentifier: locale_str] objectForKey: NSLocaleCurrencyCode]]) {
-	NSArray *all_locales = [NSLocale availableLocaleIdentifiers];
-	NSEnumerator *locale_iter = [all_locales objectEnumerator];
-	NSString *this_locale;
-	NSString *currency = [locale objectForKey: NSLocaleCurrencyCode];
-	NSString *money_locale = nil;
-	while ((this_locale = (NSString*)[locale_iter nextObject]))
-	{
-	    NSLocale *templocale = [[NSLocale alloc]
-				    initWithLocaleIdentifier: this_locale];
-	    if ([[templocale objectForKey: NSLocaleCurrencyCode]
-		 isEqualToString: currency])
-	    {
-		money_locale = this_locale;
-		[templocale release];
-		break;
-	    }
-	    [templocale release];
-	}
-	if (money_locale)
-	    setlocale(LC_MONETARY, [money_locale UTF8String]);
+	  [cur_locale objectForKey: NSLocaleCurrencyCode]])
+    {
+        NSArray *all_locales = [NSLocale availableLocaleIdentifiers];
+        NSEnumerator *locale_iter = [all_locales objectEnumerator];
+        NSString *this_locale;
+        NSString *currency = [locale objectForKey: NSLocaleCurrencyCode];
+        NSString *money_locale = nil;
+        while ((this_locale = (NSString*)[locale_iter nextObject]))
+        {
+            NSLocale *templocale = [[NSLocale alloc]
+                                    initWithLocaleIdentifier: this_locale];
+            if ([[templocale objectForKey: NSLocaleCurrencyCode]
+                 isEqualToString: currency])
+            {
+                money_locale = this_locale;
+                [templocale release];
+                break;
+            }
+            [templocale release];
+        }
+        if (money_locale)
+            setlocale(LC_MONETARY, [money_locale UTF8String]);
     }
+    [cur_locale release];
 }
 /* The locale that we got from AppKit isn't a supported POSIX one, so we need to
  * find something close. First see if we can find another locale for the
@@ -219,9 +222,7 @@ mac_find_close_country(NSString *locale_str, NSString *country_str,
             new_locale = this_locale;
             break;
         }
-    if (new_locale)
-        locale_str = new_locale;
-    else
+    if (!new_locale)
         while ((this_locale = (NSString*)[locale_iter nextObject]))
             if ([[[NSLocale componentsFromLocaleIdentifier: this_locale]
                   objectForKey: NSLocaleLanguageCode]
diff --git a/gnucash/import-export/bi-import/dialog-bi-import.c b/gnucash/import-export/bi-import/dialog-bi-import.c
index 07e6cab..5b46e84 100644
--- a/gnucash/import-export/bi-import/dialog-bi-import.c
+++ b/gnucash/import-export/bi-import/dialog-bi-import.c
@@ -879,15 +879,15 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
 static char * un_escape(char *str)
 {
     gchar quote = '"';
-    gchar *newStr = NULL;
+    gchar *newStr = NULL, *tmpstr = str;
     int n = 0;
     newStr = g_malloc(strlen(str)+1); // This must be freed in the calling code.
-    while(*str != '\0')
+    while(*tmpstr != '\0')
     {
-        if(*str == quote)
+        if(*tmpstr == quote)
         {
-            str++;
-            if(*str == quote)
+            tmpstr++;
+            if(*tmpstr == quote)
             {
                 newStr[n] = quote;
             }
@@ -896,9 +896,10 @@ static char * un_escape(char *str)
         {
             newStr[n] = *str;
         }
-            str++;
+            tmpstr++;
             n++;
-        }
+    }
+    g_free (str);
 	newStr[n] = '\0'; //ending the character array
     return newStr;
 }
diff --git a/gnucash/import-export/customer-import/dialog-customer-import.c b/gnucash/import-export/customer-import/dialog-customer-import.c
index a095417..758ce8c 100644
--- a/gnucash/import-export/customer-import/dialog-customer-import.c
+++ b/gnucash/import-export/customer-import/dialog-customer-import.c
@@ -336,7 +336,6 @@ gnc_customer_import_create_customers (GtkListStore *store, QofBook *book, guint
         // Set the customer id if one has not been chosen
         if (strlen (id) == 0)
         {
-            g_free (id);
             if (g_ascii_strcasecmp (type, "CUSTOMER") == 0) id = gncCustomerNextID (book);
             else if (g_ascii_strcasecmp (type, "VENDOR") == 0)id = gncVendorNextID (book);
             //printf("ASSIGNED ID = %s\n",id);
@@ -413,6 +412,7 @@ gnc_customer_import_create_customers (GtkListStore *store, QofBook *book, guint
             //printf("TYPE %s created with ID = %s.\n", type, id); // DEBUG
         }
 
+        g_free (id);
         g_free (company);
         g_free (name);
         g_free (addr1);
diff --git a/libgnucash/app-utils/gnc-exp-parser.c b/libgnucash/app-utils/gnc-exp-parser.c
index 24f0b9e..2e303f9 100644
--- a/libgnucash/app-utils/gnc-exp-parser.c
+++ b/libgnucash/app-utils/gnc-exp-parser.c
@@ -230,6 +230,7 @@ make_predefined_vars_from_external_helper( gpointer key, gpointer value, gpointe
         pnum->value = *(gnc_numeric*)value;
 
     make_predefined_vars_helper( key, pnum, data );
+    g_free(pnum); /* make_predefined_vars_helper allocs its own copy. */
 }
 
 static var_store_ptr
diff --git a/libgnucash/backend/xml/gnc-xml-backend.cpp b/libgnucash/backend/xml/gnc-xml-backend.cpp
index 2c0ca21..61a73ba 100644
--- a/libgnucash/backend/xml/gnc-xml-backend.cpp
+++ b/libgnucash/backend/xml/gnc-xml-backend.cpp
@@ -378,6 +378,7 @@ GncXmlBackend::write_to_file (bool make_backup)
 
     if (!mktemp (tmp_name))
     {
+        g_free (tmp_name);
         set_error(ERR_BACKEND_MISC);
         set_message("Failed to make temp file");
         LEAVE ("");
@@ -388,6 +389,7 @@ GncXmlBackend::write_to_file (bool make_backup)
     {
         if (!backup_file ())
         {
+            g_free (tmp_name);
             LEAVE ("");
             return FALSE;
         }
@@ -513,6 +515,7 @@ GncXmlBackend::write_to_file (bool make_backup)
         LEAVE ("");
         return FALSE;
     }
+    g_free (tmp_name);
     LEAVE ("");
     return TRUE;
 }
diff --git a/libgnucash/backend/xml/io-gncxml-v1.cpp b/libgnucash/backend/xml/io-gncxml-v1.cpp
index ef3ad33..af0177b 100644
--- a/libgnucash/backend/xml/io-gncxml-v1.cpp
+++ b/libgnucash/backend/xml/io-gncxml-v1.cpp
@@ -765,49 +765,42 @@ kvp_frame_slot_end_handler (gpointer data_for_children,
 {
     KvpFrame* f = (KvpFrame*) parent_data;
     GSList* lp;
-    guint64 key_node_count;
+    gboolean first = TRUE;
     gchar* key = NULL;
-    sixtp_child_result* value_cr = NULL;
     KvpValue* value = NULL;
     gboolean delete_value = FALSE;
-
+    sixtp_child_result *cr1 = NULL, *cr2 = NULL, *cr = NULL;
     g_return_val_if_fail (f, FALSE);
 
     if (g_slist_length (data_from_children) != 2) return (FALSE);
-
-    /* check to see that we got exactly one <key> node */
-    lp = data_from_children;
-    key_node_count = 0;
-    for (lp = data_from_children; lp; lp = lp->next)
+    cr1 = (sixtp_child_result*)data_from_children->data;
+    cr2 = (sixtp_child_result*)data_from_children->next->data;
+    
+    if (is_child_result_from_node_named(cr1, "k"))
     {
-        sixtp_child_result* cr = (sixtp_child_result*) lp->data;
-
-        if (is_child_result_from_node_named (cr, "k"))
-        {
-            key = (char*) cr->data;
-            key_node_count++;
-        }
-        else
-        {
-            if (is_child_result_from_node_named (cr, "frame"))
-            {
-                KvpFrame* frame = static_cast<KvpFrame*> (cr->data);
-                value = new KvpValue {frame};
-                delete_value = TRUE;
-            }
-            else
-            {
-                value = static_cast<KvpValue*> (cr->data);
-                delete_value = FALSE;
-            }
-
-            value_cr = cr;
-        }
+        key = (char*)cr1->data;
+        cr = cr2;
     }
-
-    if (key_node_count != 1) return (FALSE);
-
-    value_cr->should_cleanup = TRUE;
+    else if (is_child_result_from_node_named(cr2, "k"))
+    {
+        key = (char*)cr2->data;
+        cr = cr1;
+    }
+    else
+        return FALSE;
+    
+    if (is_child_result_from_node_named (cr, "frame"))
+    {
+        KvpFrame* frame = static_cast<KvpFrame*> (cr->data);
+        value = new KvpValue {frame};
+        delete_value = TRUE;
+    }
+    else
+    {
+        value = static_cast<KvpValue*> (cr->data);
+        delete_value = FALSE;
+    }
+    
     f->set ({key}, value);
     if (delete_value)
         delete value;
diff --git a/libgnucash/backend/xml/io-gncxml-v2.cpp b/libgnucash/backend/xml/io-gncxml-v2.cpp
index 55e4395..3c04094 100644
--- a/libgnucash/backend/xml/io-gncxml-v2.cpp
+++ b/libgnucash/backend/xml/io-gncxml-v2.cpp
@@ -1868,6 +1868,7 @@ gnc_xml2_find_ambiguous (const gchar* filename, GList* encodings,
         if (iconv_item->iconv == (GIConv) - 1)
         {
             PWARN ("Unable to open IConv conversion descriptor for '%s'", enc);
+            g_free (iconv_item);
             goto cleanup_find_ambs;
         }
         else
@@ -2176,7 +2177,8 @@ gnc_xml2_parse_with_subst (GncXmlBackend* xml_be, QofBook* book, GHashTable* sub
     success = qof_session_load_from_xml_file_v2_full (
                   xml_be, book, (sixtp_push_handler) parse_with_subst_push_handler,
                   push_data, GNC_BOOK_XML2_FILE);
-
+    g_free (push_data);
+    
     if (success)
         qof_instance_set_dirty (QOF_INSTANCE (book));
 
diff --git a/libgnucash/backend/xml/sixtp.cpp b/libgnucash/backend/xml/sixtp.cpp
index 2064d7f..95f4995 100644
--- a/libgnucash/backend/xml/sixtp.cpp
+++ b/libgnucash/backend/xml/sixtp.cpp
@@ -267,20 +267,22 @@ sixtp_destroy_child (gpointer key, gpointer value, gpointer user_data)
     gpointer lookup_value;
 
     g_debug ("Killing sixtp child under key <%s>", key ? (char*) key : "(null)");
-    g_free (key);
 
     if (!corpses)
     {
         g_critical ("no corpses in sixtp_destroy_child <%s>",
                     key ? (char*) key : "(null)");
+        g_free (key);
         return;
     }
     if (!child)
     {
         g_critical ("no child in sixtp_destroy_child <%s>",
                     key ? (char*) key : "");
+        g_free (key);
         return;
     }
+    g_free (key);
 
     if (!g_hash_table_lookup_extended (corpses, (gconstpointer) child,
                                        &lookup_key, &lookup_value))
diff --git a/libgnucash/core-utils/gnc-environment.c b/libgnucash/core-utils/gnc-environment.c
index 8d0e102..fc44733 100644
--- a/libgnucash/core-utils/gnc-environment.c
+++ b/libgnucash/core-utils/gnc-environment.c
@@ -146,9 +146,10 @@ gnc_environment_parse_one (const gchar *env_path)
 
             /* Remove the "x" from our result */
             if (g_strcmp0 (tmp_val, "x"))
+            {
                 new_val = g_strdup (tmp_val + sizeof (G_SEARCHPATH_SEPARATOR_S));
-            g_free (tmp_val);
-
+                g_free (tmp_val);
+            }
             if (!g_setenv (env_vars[i], new_val, TRUE))
                 g_warning ("Couldn't properly override environment variable \"%s\". "
                 "This may lead to unexpected results", env_vars[i]);
diff --git a/libgnucash/engine/gnc-commodity.c b/libgnucash/engine/gnc-commodity.c
index f7b6c0c..2a028ce 100644
--- a/libgnucash/engine/gnc-commodity.c
+++ b/libgnucash/engine/gnc-commodity.c
@@ -2457,8 +2457,8 @@ gnc_commodity_table_destroy(gnc_commodity_table * t)
     t->ns_list = NULL;
     g_hash_table_destroy(t->ns_table);
     t->ns_table = NULL;
-    g_free(t);
     LEAVE ("table=%p", t);
+    g_free(t);
 }
 
 /* =========================================================== */
diff --git a/libgnucash/engine/qofid.cpp b/libgnucash/engine/qofid.cpp
index ac689ff..1f50e95 100644
--- a/libgnucash/engine/qofid.cpp
+++ b/libgnucash/engine/qofid.cpp
@@ -234,6 +234,7 @@ qof_collection_from_glist (QofIdType type, const GList *glist)
         ent = QOF_INSTANCE(list->data);
         if (FALSE == qof_collection_add_entity(coll, ent))
         {
+            qof_collection_destroy(coll);
             return NULL;
         }
     }



Summary of changes:
 CMakeLists.txt                                     |  4 ++
 borrowed/gwengui-gtk3/gtk3_gui_dialog.c            |  2 -
 borrowed/gwengui-gtk3/w_checkbox.c                 | 11 ++--
 borrowed/gwengui-gtk3/w_combobox.c                 |  9 ++--
 borrowed/gwengui-gtk3/w_dialog.c                   |  2 -
 borrowed/gwengui-gtk3/w_gridlayout.c               |  4 --
 borrowed/gwengui-gtk3/w_groupbox.c                 |  2 -
 borrowed/gwengui-gtk3/w_hlayout.c                  |  2 -
 borrowed/gwengui-gtk3/w_hline.c                    |  2 -
 borrowed/gwengui-gtk3/w_hspacer.c                  |  2 -
 borrowed/gwengui-gtk3/w_label.c                    |  2 -
 borrowed/gwengui-gtk3/w_lineedit.c                 | 18 +++----
 borrowed/gwengui-gtk3/w_listbox.c                  | 13 ++---
 borrowed/gwengui-gtk3/w_progressbar.c              |  4 --
 borrowed/gwengui-gtk3/w_pushbutton.c               | 11 ++--
 borrowed/gwengui-gtk3/w_radiobutton.c              | 10 ++--
 borrowed/gwengui-gtk3/w_scrollarea.c               |  2 -
 borrowed/gwengui-gtk3/w_spinbox.c                  | 13 ++---
 borrowed/gwengui-gtk3/w_stack.c                    |  2 -
 borrowed/gwengui-gtk3/w_tabbook.c                  |  2 -
 borrowed/gwengui-gtk3/w_textbrowser.c              |  2 -
 borrowed/gwengui-gtk3/w_textedit.c                 |  5 +-
 borrowed/gwengui-gtk3/w_vlayout.c                  |  2 -
 borrowed/gwengui-gtk3/w_vline.c                    |  2 -
 borrowed/gwengui-gtk3/w_vspacer.c                  |  2 -
 borrowed/jenny/jenny.c                             |  9 +---
 gnucash/gnome-utils/assistant-xml-encoding.c       |  2 +-
 gnucash/gnome-utils/dialog-commodity.c             |  2 +-
 gnucash/gnome-utils/dialog-preferences.c           |  2 +-
 gnucash/gnome-utils/dialog-reset-warnings.c        |  3 +-
 gnucash/gnome-utils/dialog-tax-table.c             |  2 +-
 gnucash/gnome-utils/dialog-totd.c                  |  7 ++-
 gnucash/gnome-utils/dialog-transfer.c              |  3 +-
 gnucash/gnome-utils/gnc-cell-renderer-date.c       |  8 +--
 gnucash/gnome-utils/gnc-cell-renderer-popup.c      |  4 +-
 gnucash/gnome-utils/gnc-date-edit.c                |  2 +-
 gnucash/gnome-utils/gnc-file.c                     |  3 +-
 gnucash/gnome-utils/gnc-main-window.c              | 11 ++--
 gnucash/gnome-utils/gnc-period-select.c            |  1 -
 gnucash/gnome-utils/gnc-query-view.c               |  2 +-
 gnucash/gnome-utils/gnc-tree-model-split-reg.c     | 12 ++---
 gnucash/gnome-utils/gnc-tree-util-split-reg.c      |  1 -
 gnucash/gnome-utils/gnc-tree-view-account.c        |  5 +-
 gnucash/gnome-utils/gnc-tree-view-commodity.c      | 10 ++--
 gnucash/gnome-utils/gnc-tree-view-price.c          |  2 +-
 gnucash/gnome-utils/gnc-tree-view-split-reg.c      | 43 ++-------------
 gnucash/gnome-utils/gnc-tree-view.c                |  1 -
 gnucash/gnome/assistant-loan.cpp                   |  3 +-
 gnucash/gnome/dialog-billterms.c                   |  5 --
 gnucash/gnome/dialog-commodities.c                 |  2 +-
 gnucash/gnome/dialog-invoice.c                     |  1 +
 gnucash/gnome/dialog-payment.c                     |  8 ++-
 gnucash/gnome/dialog-price-edit-db.c               |  2 +-
 gnucash/gnome/dialog-print-check.c                 |  4 +-
 gnucash/gnome/dialog-sx-editor.c                   |  2 +-
 gnucash/gnome/dialog-sx-editor2.c                  |  4 +-
 gnucash/gnome/dialog-sx-from-trans.c               |  2 +-
 gnucash/gnome/dialog-sx-since-last-run.c           |  2 +-
 gnucash/gnome/gnc-budget-view.c                    |  2 +-
 gnucash/gnome/gnc-plugin-page-account-tree.c       |  1 +
 gnucash/gnome/gnc-plugin-page-register.c           |  2 -
 gnucash/gnome/gnc-plugin-page-register2.c          |  1 -
 gnucash/gnome/gnc-split-reg.c                      | 10 ++--
 gnucash/gnome/gnc-split-reg2.c                     | 12 ++---
 gnucash/gnome/reconcile-view.c                     |  4 +-
 gnucash/gnome/window-reconcile.c                   |  8 +--
 gnucash/gnome/window-reconcile2.c                  |  8 +--
 gnucash/gnucash-bin.c                              | 49 ++++++++---------
 gnucash/import-export/aqb/dialog-ab-trans.c        | 21 ++------
 gnucash/import-export/bi-import/dialog-bi-import.c | 15 +++---
 .../csv-imp/assistant-csv-price-import.cpp         |  3 +-
 .../csv-imp/assistant-csv-trans-import.cpp         |  1 -
 .../import-export/csv-imp/gnc-imp-props-price.cpp  |  2 +-
 gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp |  2 +-
 .../customer-import/dialog-customer-import.c       |  2 +-
 gnucash/import-export/import-account-matcher.c     |  4 +-
 gnucash/import-export/log-replay/gnc-log-replay.c  |  1 -
 gnucash/import-export/ofx/gnc-ofx-import.c         |  2 +-
 gnucash/register/ledger-core/gncEntryLedger.c      |  2 +-
 gnucash/register/ledger-core/split-register-load.c |  1 -
 .../ledger-core/split-register-model-save.c        |  2 +-
 .../register/ledger-core/split-register-model.c    |  4 +-
 gnucash/register/register-gnome/combocell-gnome.c  |  2 -
 gnucash/register/register-gnome/gnucash-cursor.c   |  2 +-
 gnucash/register/register-gnome/gnucash-header.c   |  2 -
 .../register/register-gnome/gnucash-item-edit.c    | 14 +++--
 .../register-gnome/gnucash-sheet-private.c         |  2 +-
 gnucash/register/register-gnome/gnucash-sheet.c    |  8 +--
 gnucash/register/register-gnome/gnucash-style.c    |  6 +--
 libgnucash/app-utils/calculation/fin.c             | 53 +++++++++---------
 libgnucash/app-utils/gnc-exp-parser.c              |  2 +-
 libgnucash/app-utils/gnc-ui-util.c                 |  1 -
 libgnucash/app-utils/option-util.c                 | 18 +++----
 libgnucash/backend/dbi/gnc-backend-dbi.cpp         |  2 +-
 libgnucash/backend/dbi/gnc-dbisqlconnection.cpp    |  4 +-
 libgnucash/backend/dbi/gnc-dbisqlresult.cpp        |  4 +-
 libgnucash/backend/sql/gnc-bill-term-sql.cpp       |  3 +-
 libgnucash/backend/sql/gnc-budget-sql.cpp          |  2 +-
 libgnucash/backend/sql/gnc-customer-sql.cpp        |  2 +-
 libgnucash/backend/sql/gnc-employee-sql.cpp        |  2 +-
 libgnucash/backend/sql/gnc-entry-sql.cpp           |  2 +-
 libgnucash/backend/sql/gnc-invoice-sql.cpp         |  2 +-
 libgnucash/backend/sql/gnc-job-sql.cpp             |  2 +-
 libgnucash/backend/sql/gnc-order-sql.cpp           |  2 +-
 libgnucash/backend/sql/gnc-sql-backend.cpp         |  2 +-
 libgnucash/backend/sql/gnc-transaction-sql.cpp     |  1 -
 libgnucash/backend/sql/gnc-vendor-sql.cpp          |  2 +-
 libgnucash/backend/xml/gnc-xml-backend.cpp         |  8 +++
 libgnucash/backend/xml/io-gncxml-v1.cpp            | 63 ++++++++++------------
 libgnucash/backend/xml/io-gncxml-v2.cpp            |  9 ++--
 libgnucash/backend/xml/io-utils.cpp                |  2 +
 libgnucash/backend/xml/sixtp.cpp                   |  4 +-
 libgnucash/core-utils/gnc-environment.c            |  5 +-
 libgnucash/engine/Account.cpp                      |  1 -
 libgnucash/engine/Scrub.c                          | 12 ++---
 libgnucash/engine/ScrubBusiness.c                  |  1 -
 libgnucash/engine/Transaction.c                    |  2 +-
 libgnucash/engine/cap-gains.c                      |  2 +-
 libgnucash/engine/engine-helpers.c                 | 15 ------
 libgnucash/engine/gnc-aqbanking-templates.cpp      |  1 -
 libgnucash/engine/gnc-commodity.c                  |  2 +-
 libgnucash/engine/gnc-int128.cpp                   |  3 ++
 libgnucash/engine/gnc-pricedb.c                    | 14 +++--
 libgnucash/engine/gnc-timezone.cpp                 |  3 --
 libgnucash/engine/gncCustomer.c                    |  9 ++--
 libgnucash/engine/gncEmployee.c                    |  9 ++--
 libgnucash/engine/gncEntry.c                       |  2 +-
 libgnucash/engine/gncInvoice.c                     |  3 +-
 libgnucash/engine/gncTaxTable.c                    |  2 +
 libgnucash/engine/gncVendor.c                      |  9 ++--
 libgnucash/engine/kvp-value.cpp                    |  1 +
 libgnucash/engine/qofbook.cpp                      |  3 +-
 libgnucash/engine/qofid.cpp                        |  1 +
 libgnucash/engine/qofinstance.cpp                  |  1 -
 libgnucash/engine/qofquery.cpp                     |  5 +-
 135 files changed, 323 insertions(+), 470 deletions(-)



More information about the gnucash-changes mailing list