I've attached a new version of the patch that fixes my compile errors and should keep the same function as before. I don't know why the compiler likes my new version better, but it does.
On Mon, 2009-10-26 at 18:54 -0400, Phil Longstaff wrote: > On October 26, 2009 04:43:18 pm Matt Lavin wrote: > > The first patch's main content was: > > > > - return (*((guint *) guid->data)); > > + return guid->data[0]; > > > > That was the real compile error. I removed the two static functions > > because they were functional duplicates of existing code and I thought it > > would be better to reduce code duplication than to fix the same compiler > > error in two spots. Of course, I didn't explain that and I should have. > > The duplicate methods could be added back if they are needed for a reason I > > overlooked. > > Won't that change the return value. Old value: contents of the first 4 bytes > of data. New value: contents of the first 1 byte. > > Phil > _______________________________________________ > gnucash-devel mailing list > [email protected] > https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>From cf95e86bde95dc111239abd259482c32eb426f2a Mon Sep 17 00:00:00 2001 Message-Id: <cf95e86bde95dc111239abd259482c32eb426f2a.1256854907.git.matt.la...@gmail.com> From: Matt Lavin <[email protected]> Date: Wed, 21 Oct 2009 10:34:43 -0400 Subject: [PATCH] Fix GCC pointer strictness compiler errors/warnings and remove duplicate code --- src/libqof/qof/guid.c | 3 ++- src/libqof/qof/qofid.c | 37 +------------------------------------ 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/src/libqof/qof/guid.c b/src/libqof/qof/guid.c index fd39690..2bb4ec9 100644 --- a/src/libqof/qof/guid.c +++ b/src/libqof/qof/guid.c @@ -713,7 +713,8 @@ guid_hash_to_guint (gconstpointer ptr) if (sizeof(guint) <= sizeof(guid->data)) { - return (*((guint *) guid->data)); + guint* int_data = (guint *) guid->data; + return (*int_data); } 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
_______________________________________________ gnucash-devel mailing list [email protected] https://lists.gnucash.org/mailman/listinfo/gnucash-devel
