I recently fetched the latest gnucash SVN source and tried to compile it
on a Ubuntu 9.10 (Karmic) machine.  I ran into a couple of compiler
warnings and thought I'd send my patches so other people don't have to
make the same fixes.




>From 77b316623aaeb9d10e31f505444b34e050c0a2a8 Mon Sep 17 00:00:00 2001
From: Matt Lavin <[email protected]>
Date: Wed, 21 Oct 2009 10:34:43 -0400
Subject: [PATCH 1/2] Fix GCC pointer strictness compiler errors/warnings and remove duplicate code

---
 src/libqof/qof/guid.c  |    2 +-
 src/libqof/qof/qofid.c |   37 +------------------------------------
 2 files changed, 2 insertions(+), 37 deletions(-)

diff --git a/src/libqof/qof/guid.c b/src/libqof/qof/guid.c
index fd39690..8589990 100644
--- a/src/libqof/qof/guid.c
+++ b/src/libqof/qof/guid.c
@@ -713,7 +713,7 @@ guid_hash_to_guint (gconstpointer ptr)
 
     if (sizeof(guint) <= sizeof(guid->data))
     {
-        return (*((guint *) guid->data));
+        return guid->data[0];
     }
     else
     {
diff --git a/src/libqof/qof/qofid.c b/src/libqof/qof/qofid.c
index f715ddb..59f7ebe 100644
--- a/src/libqof/qof/qofid.c
+++ b/src/libqof/qof/qofid.c
@@ -58,48 +58,13 @@ qof_set_alt_dirty_mode (gboolean enabled)
 
 /* =============================================================== */
 
-static guint
-id_hash (gconstpointer key)
-{
-    const GUID *guid = key;
-
-    if (key == NULL)
-        return 0;
-
-    /* Compiler should optimize this all away! */
-    if (sizeof(guint) <= 16)
-        return *((guint *) guid->data);
-    else
-    {
-        guint hash = 0;
-        unsigned int i, j;
-
-        for (i = 0, j = 0; i < sizeof(guint); i++, j++)
-        {
-            if (j == 16)
-                j = 0;
-
-            hash <<= 4;
-            hash |= guid->data[j];
-        }
-
-        return hash;
-    }
-}
-
-static gboolean
-id_compare(gconstpointer key_1, gconstpointer key_2)
-{
-    return guid_equal (key_1, key_2);
-}
-
 QofCollection *
 qof_collection_new (QofIdType type)
 {
     QofCollection *col;
     col = g_new0(QofCollection, 1);
     col->e_type = CACHE_INSERT (type);
-    col->hash_of_entities = g_hash_table_new (id_hash, id_compare);
+    col->hash_of_entities = guid_hash_table_new();
     col->data = NULL;
     return col;
 }
-- 
1.6.3.3

>From 8320548273a0bd57a77b19ab25e07a478d5a0ea1 Mon Sep 17 00:00:00 2001
From: Matt Lavin <[email protected]>
Date: Wed, 21 Oct 2009 19:57:14 -0400
Subject: [PATCH 2/2] Fix compile error related to uninitialized value

---
 src/import-export/gnc-import-format-gnome.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/import-export/gnc-import-format-gnome.c b/src/import-export/gnc-import-format-gnome.c
index 02101a2..8ea2b1f 100644
--- a/src/import-export/gnc-import-format-gnome.c
+++ b/src/import-export/gnc-import-format-gnome.c
@@ -64,17 +64,16 @@ gnc_ifg_option_changed (GtkComboBox *combo, GNCImportProvFormatGnome *prov_f)
 {
   GtkTreeModel *model;
   GtkTreeIter iter;
-  gint value;
+  GncImportFormat value;
 
   g_return_if_fail(GTK_IS_COMBO_BOX(combo));
-  g_return_if_fail(value);
 
   model = gtk_combo_box_get_model(combo);
   if (!gtk_combo_box_get_active_iter(combo, &iter))
     return;
 
   gtk_tree_model_get(model, &iter, IFG_COL_VALUE, &value, -1);
-  prov_f->choice = (GncImportFormat)value;
+  prov_f->choice = value;
 }
 
 #define ADD_MENU_ITEM(str,op) { \
-- 
1.6.3.3

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

Reply via email to