From a2e2bda6d8260da48c0bc6c05ce62f6a5eefb8cd Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Sat, 12 Apr 2003 16:53:22 +0000 Subject: [PATCH] Applied Herbert Thoma's patch: * lots of files... fixes for GCC 3.3 warnings comparison between signed and unsigned and dereferencing type-punned pointer will break strict-aliasing rules fixes #110320 * src/engine/gnc-pricedb-p.h * src/engine/gnc-pricedb.c * src/engine/gnc-pricedb.h: gnc_pricedb_lookup_at_time_any_currency, gnc_pricedb_lookup_day_any_currency and gnc_pricedb_lookup_nearest_in_time_any_currency functions git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8223 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 43 ++++ src/backend/file/sixtp-dom-parsers.c | 2 +- src/backend/file/sixtp-utils.c | 2 +- src/backend/file/test/test-dom-converters1.c | 2 +- .../file/test/test-string-converters.c | 2 +- .../business-ledger/gncEntryLedgerLayout.c | 2 +- .../business-ledger/gncEntryLedgerModel.c | 2 +- src/calculation/fin.c | 2 +- src/engine/GNCId.c | 2 +- src/engine/QueryCore.c | 2 +- src/engine/gnc-engine-util.c | 2 +- src/engine/gnc-pricedb-p.h | 8 + src/engine/gnc-pricedb.c | 224 +++++++++++++++++- src/engine/gnc-pricedb.h | 43 +++- src/engine/guid.c | 4 +- src/engine/test/test-commodities.c | 2 +- src/gnome-utils/dialog-options.c | 3 +- src/gnome-utils/dialog-utils.c | 5 +- src/gnome-utils/gnc-dense-cal.c | 9 +- src/gnome-utils/gnc-frequency.c | 2 +- src/gnome-utils/gnc-html.c | 18 +- src/gnome/dialog-fincalc.c | 2 +- src/gnome/dialog-scheduledxaction.c | 10 +- src/gnome/dialog-sx-from-trans.c | 2 +- src/gnome/gnc-split-reg.h | 2 +- src/gnome/reconcile-list.h | 2 +- src/import-export/import-account-matcher.c | 2 +- src/network-utils/gnc-gpg.c | 2 +- src/register/register-core/formulacell.c | 4 +- src/register/register-core/pricecell.c | 4 +- src/register/register-gnome/combocell-gnome.c | 2 +- src/register/register-gnome/datecell-gnome.c | 2 +- src/register/register-gnome/gnucash-sheet.h | 2 +- 33 files changed, 362 insertions(+), 55 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb03a6792a..81a0f246b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,46 @@ +2003-04-12 Herbert Thoma + + * src/backend/file/sixtp-dom-parsers.c + * src/backend/file/sixtp-utils.c + * src/backend/file/test/test-dom-converters1.c + * src/backend/file/test/test-string-converters.c + * src/business/business-ledger/gncEntryLedgerLayout.c + * src/business/business-ledger/gncEntryLedgerModel.c + * src/calculation/fin.c + * src/engine/GNCId.c + * src/engine/QueryCore.c + * src/engine/gnc-engine-util.c + * src/engine/guid.c + * src/engine/test/test-commodities.c + * src/gnome-utils/dialog-options.c + * src/gnome-utils/dialog-utils.c + * src/gnome-utils/gnc-dense-cal.c + * src/gnome-utils/gnc-frequency.c + * src/gnome-utils/gnc-html.c + * src/gnome/dialog-fincalc.c + * src/gnome/dialog-scheduledxaction.c + * src/gnome/dialog-sx-from-trans.c + * src/gnome/gnc-split-reg.h + * src/gnome/reconcile-list.h + * src/import-export/import-account-matcher.c + * src/network-utils/gnc-gpg.c + * src/register/register-core/formulacell.c + * src/register/register-core/pricecell.c + * src/register/register-gnome/combocell-gnome.c + * src/register/register-gnome/datecell-gnome.c + * src/register/register-gnome/gnucash-sheet.h: + fixes for GCC 3.3 warnings + comparison between signed and unsigned and + dereferencing type-punned pointer will break strict-aliasing rules + fixes #110320 + + * src/engine/gnc-pricedb-p.h + * src/engine/gnc-pricedb.c + * src/engine/gnc-pricedb.h: + gnc_pricedb_lookup_at_time_any_currency, + gnc_pricedb_lookup_day_any_currency and + gnc_pricedb_lookup_nearest_in_time_any_currency functions + 2003-04-11 Derek Atkins * src/engine/Transaction.c: xaccSplitGetCorrAccountCode() should diff --git a/src/backend/file/sixtp-dom-parsers.c b/src/backend/file/sixtp-dom-parsers.c index 362907dbb5..f3f4003b58 100644 --- a/src/backend/file/sixtp-dom-parsers.c +++ b/src/backend/file/sixtp-dom-parsers.c @@ -206,7 +206,7 @@ string_to_binary(const gchar *str, void **v, guint64 *data_len) { guint64 str_len; guchar *data; - int i, j; + unsigned int i, j; g_return_val_if_fail(v != NULL, FALSE); g_return_val_if_fail(data_len != NULL, FALSE); diff --git a/src/backend/file/sixtp-utils.c b/src/backend/file/sixtp-utils.c index b20a403978..7d3afcb393 100644 --- a/src/backend/file/sixtp-utils.c +++ b/src/backend/file/sixtp-utils.c @@ -496,7 +496,7 @@ gboolean string_to_timespec_nsecs(const gchar *str, Timespec *ts) { long int nanosecs; - int charcount; + unsigned int charcount; if (!str || !ts) return FALSE; diff --git a/src/backend/file/test/test-dom-converters1.c b/src/backend/file/test/test-dom-converters1.c index db2713a77a..b512697838 100644 --- a/src/backend/file/test/test-dom-converters1.c +++ b/src/backend/file/test/test-dom-converters1.c @@ -201,7 +201,7 @@ test_dom_tree_to_gnc_numeric(void) gchar *message = NULL; message = test_gnc_nums_internal - (gnc_numeric_create(18768786810, 100000)); + (gnc_numeric_create(18768786810LL, 100000)); do_test_args(message == NULL, "gnc_num 18768786810/100000", __FILE__, __LINE__, message); diff --git a/src/backend/file/test/test-string-converters.c b/src/backend/file/test/test-string-converters.c index cf020dfdb8..86af2dc21c 100644 --- a/src/backend/file/test/test-string-converters.c +++ b/src/backend/file/test/test-string-converters.c @@ -23,7 +23,7 @@ test_binary() { bin_data *test_data1; void *test_data2; - guint64 test_data2_len; + gint64 test_data2_len; gchar *converted; test_data1 = get_random_binary_data(); diff --git a/src/business/business-ledger/gncEntryLedgerLayout.c b/src/business/business-ledger/gncEntryLedgerLayout.c index 28bb9eab2d..3a246f2b61 100644 --- a/src/business/business-ledger/gncEntryLedgerLayout.c +++ b/src/business/business-ledger/gncEntryLedgerLayout.c @@ -97,7 +97,7 @@ static void gnc_entry_ledger_layout_add_cells (GncEntryLedger *ledger, { ENTRY_PAYMENT_CELL, COMBO_CELL_TYPE_NAME, N_("sample:Payment")+7, CELL_ALIGN_LEFT, FALSE, FALSE } }; - int i; + unsigned int i; for (i = 0; i < (sizeof(cells)/sizeof(*cells)); i++) gnc_register_add_cell (layout, cells[i].cell_name, cells[i].cell_type_name, diff --git a/src/business/business-ledger/gncEntryLedgerModel.c b/src/business/business-ledger/gncEntryLedgerModel.c index bb5e88add5..7dd2a467c2 100644 --- a/src/business/business-ledger/gncEntryLedgerModel.c +++ b/src/business/business-ledger/gncEntryLedgerModel.c @@ -1127,7 +1127,7 @@ static void gnc_entry_ledger_model_new_handlers (TableModel *model, { ENTRY_BILLABLE_CELL, get_billable_entry, get_billable_label, get_billable_help, get_typecell_io_flags }, { ENTRY_PAYMENT_CELL, get_payment_entry, get_payment_label, get_payment_help, get_standard_io_flags }, }; - int i; + unsigned int i; gnc_table_model_set_default_bg_color_handler (model, gnc_entry_ledger_get_bg_color); diff --git a/src/calculation/fin.c b/src/calculation/fin.c index b0dedff90f..b0fb6ba9fc 100644 --- a/src/calculation/fin.c +++ b/src/calculation/fin.c @@ -2418,7 +2418,7 @@ Amortization_Schedule (amort_sched_ptr amortsched) for (jj = n, j = 0; jj > 0; jj -= yr_pmt, yr_pmt = PF, j++) { - if (jj <= PF) + if (jj <= (int)PF) { yr_fv = fv; yr_int = rnd (((jj - 1) * pmt) + hpv + final_pmt, prec); diff --git a/src/engine/GNCId.c b/src/engine/GNCId.c index bf97ffe761..9886fd2ad4 100644 --- a/src/engine/GNCId.c +++ b/src/engine/GNCId.c @@ -131,7 +131,7 @@ id_hash (gconstpointer key) else { guint hash = 0; - int i, j; + unsigned int i, j; for (i = 0, j = 0; i < sizeof(guint); i++, j++) { diff --git a/src/engine/QueryCore.c b/src/engine/QueryCore.c index 1da94c843f..488b3c117e 100644 --- a/src/engine/QueryCore.c +++ b/src/engine/QueryCore.c @@ -1018,7 +1018,7 @@ QueryPredData_t gncQueryKVPPredicate (query_compare_t how, static void init_tables (void) { - int i; + unsigned int i; struct { char const *name; QueryPredicate pred; diff --git a/src/engine/gnc-engine-util.c b/src/engine/gnc-engine-util.c index dca92bba0c..412272d9ba 100644 --- a/src/engine/gnc-engine-util.c +++ b/src/engine/gnc-engine-util.c @@ -372,7 +372,7 @@ ultostr (unsigned long val, int base) } /* print */ - for (i=0; ibroke[i]) { buf[places-1-i] = 0x30+broke[i]; /* ascii digit zero */ } else { diff --git a/src/engine/gnc-pricedb-p.h b/src/engine/gnc-pricedb-p.h index 95800d4dbf..f92984df85 100644 --- a/src/engine/gnc-pricedb-p.h +++ b/src/engine/gnc-pricedb-p.h @@ -87,6 +87,14 @@ struct gnc_price_lookup_s Timespec date; }; + +typedef struct gnc_price_lookup_helper_s +{ + GList **return_list; + Timespec time; +} GNCPriceLookupHelper; + + void gnc_pricedb_mark_clean(GNCPriceDB *db); void gnc_pricedb_substitute_commodity(GNCPriceDB *db, gnc_commodity *old_c, diff --git a/src/engine/gnc-pricedb.c b/src/engine/gnc-pricedb.c index 890850c6a7..5f0c330747 100644 --- a/src/engine/gnc-pricedb.c +++ b/src/engine/gnc-pricedb.c @@ -989,6 +989,7 @@ gnc_pricedb_lookup_latest(GNCPriceDB *db, return result; } + static void lookup_latest(gpointer key, gpointer val, gpointer user_data) { @@ -998,7 +999,7 @@ lookup_latest(gpointer key, gpointer val, gpointer user_data) if(!price_list) return; - /* the latest price ist the first in list */ + /* the latest price is the first in list */ gnc_price_list_insert(return_list, price_list->data); } @@ -1014,6 +1015,15 @@ gnc_pricedb_lookup_latest_any_currency(GNCPriceDB *db, ENTER ("db=%p commodity=%p", db, commodity); if(!db || !commodity) return NULL; + if (db->book && db->book->backend && db->book->backend->price_lookup) + { + GNCPriceLookup pl; + pl.type = LOOKUP_LATEST; + pl.prdb = db; + pl.commodity = commodity; + (db->book->backend->price_lookup) (db->book->backend, &pl); + } + currency_hash = g_hash_table_lookup(db->commodity_hash, commodity); if(!currency_hash) return NULL; @@ -1027,6 +1037,7 @@ gnc_pricedb_lookup_latest_any_currency(GNCPriceDB *db, return result; } + GList * gnc_pricedb_get_prices(GNCPriceDB *db, gnc_commodity *commodity, @@ -1064,6 +1075,7 @@ gnc_pricedb_get_prices(GNCPriceDB *db, return result; } + GList * gnc_pricedb_lookup_day(GNCPriceDB *db, gnc_commodity *c, @@ -1113,6 +1125,68 @@ gnc_pricedb_lookup_day(GNCPriceDB *db, } +static void +lookup_day(gpointer key, gpointer val, gpointer user_data) +{ + //gnc_commodity *currency = (gnc_commodity *)key; + GList *price_list = (GList *)val; + GList *item = NULL; + GNCPriceLookupHelper *lookup_helper = (GNCPriceLookupHelper *)user_data; + GList **return_list = lookup_helper->return_list; + Timespec t = lookup_helper->time; + + item = price_list; + while(item) { + GNCPrice *p = item->data; + Timespec price_time = timespecCanonicalDayTime(gnc_price_get_time(p)); + if(timespec_equal(&price_time, &t)) { + gnc_price_list_insert(return_list, item->data); + } + item = item->next; + } +} + +GList * +gnc_pricedb_lookup_day_any_currency(GNCPriceDB *db, + gnc_commodity *c, + Timespec t) +{ + GList *result = NULL; + GHashTable *currency_hash; + GNCPriceLookupHelper lookup_helper; + + ENTER ("db=%p commodity=%p", db, c); + if(!db || !c) return NULL; + + /* Convert to noon local time. */ + t = timespecCanonicalDayTime(t); + + if (db->book && db->book->backend && db->book->backend->price_lookup) + { + GNCPriceLookup pl; + pl.type = LOOKUP_AT_TIME; + pl.prdb = db; + pl.commodity = c; + pl.date = t; + (db->book->backend->price_lookup) (db->book->backend, &pl); + } + + currency_hash = g_hash_table_lookup(db->commodity_hash, c); + if(!currency_hash) return NULL; + + lookup_helper.return_list = &result; + lookup_helper.time = t; + g_hash_table_foreach(currency_hash, lookup_day, &lookup_helper); + + if(!result) return NULL; + + result = g_list_sort(result, compare_prices_by_date); + + LEAVE (" "); + return result; +} + + GList * gnc_pricedb_lookup_at_time(GNCPriceDB *db, gnc_commodity *c, @@ -1158,6 +1232,64 @@ gnc_pricedb_lookup_at_time(GNCPriceDB *db, return result; } +static void +lookup_time(gpointer key, gpointer val, gpointer user_data) +{ + //gnc_commodity *currency = (gnc_commodity *)key; + GList *price_list = (GList *)val; + GList *item = NULL; + GNCPriceLookupHelper *lookup_helper = (GNCPriceLookupHelper *)user_data; + GList **return_list = lookup_helper->return_list; + Timespec t = lookup_helper->time; + + item = price_list; + while(item) { + GNCPrice *p = item->data; + Timespec price_time = gnc_price_get_time(p); + if(timespec_equal(&price_time, &t)) { + gnc_price_list_insert(return_list, item->data); + } + item = item->next; + } +} + +GList * +gnc_pricedb_lookup_at_time_any_currency(GNCPriceDB *db, + gnc_commodity *c, + Timespec t) +{ + GList *result = NULL; + GHashTable *currency_hash; + GNCPriceLookupHelper lookup_helper; + + ENTER ("db=%p commodity=%p", db, c); + if(!db || !c) return NULL; + + if (db->book && db->book->backend && db->book->backend->price_lookup) + { + GNCPriceLookup pl; + pl.type = LOOKUP_AT_TIME; + pl.prdb = db; + pl.commodity = c; + pl.date = t; + (db->book->backend->price_lookup) (db->book->backend, &pl); + } + + currency_hash = g_hash_table_lookup(db->commodity_hash, c); + if(!currency_hash) return NULL; + + lookup_helper.return_list = &result; + lookup_helper.time = t; + g_hash_table_foreach(currency_hash, lookup_time, &lookup_helper); + + if(!result) return NULL; + + result = g_list_sort(result, compare_prices_by_date); + + LEAVE (" "); + return result; +} + GNCPrice * gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db, @@ -1234,6 +1366,96 @@ gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db, return result; } +static void +lookup_nearest(gpointer key, gpointer val, gpointer user_data) +{ + //gnc_commodity *currency = (gnc_commodity *)key; + GList *price_list = (GList *)val; + GNCPrice *current_price = NULL; + GNCPrice *next_price = NULL; + GNCPrice *result = NULL; + GList *item = NULL; + GNCPriceLookupHelper *lookup_helper = (GNCPriceLookupHelper *)user_data; + GList **return_list = lookup_helper->return_list; + Timespec t = lookup_helper->time; + + item = price_list; + + /* default answer */ + current_price = item->data; + + /* find the first candidate past the one we want. Remember that + prices are in most-recent-first order. */ + while (!next_price && item) { + GNCPrice *p = item->data; + Timespec price_time = gnc_price_get_time(p); + if (timespec_cmp(&price_time, &t) <= 0) { + next_price = item->data; + break; + } + current_price = item->data; + item = item->next; + } + + if (current_price) { + if (!next_price) { + result = current_price; + } else { + Timespec current_t = gnc_price_get_time(current_price); + Timespec next_t = gnc_price_get_time(next_price); + Timespec diff_current = timespec_diff(¤t_t, &t); + Timespec diff_next = timespec_diff(&next_t, &t); + Timespec abs_current = timespec_abs(&diff_current); + Timespec abs_next = timespec_abs(&diff_next); + + if (timespec_cmp(&abs_current, &abs_next) <= 0) { + result = current_price; + } else { + result = next_price; + } + } + } + + gnc_price_list_insert(return_list, result); +} + +GList * +gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db, + gnc_commodity *c, + Timespec t) +{ + GList *result = NULL; + GHashTable *currency_hash; + GNCPriceLookupHelper lookup_helper; + + ENTER ("db=%p commodity=%p", db, c); + if(!db || !c) return NULL; + + if (db->book && db->book->backend && db->book->backend->price_lookup) + { + GNCPriceLookup pl; + pl.type = LOOKUP_NEAREST_IN_TIME; + pl.prdb = db; + pl.commodity = c; + pl.date = t; + (db->book->backend->price_lookup) (db->book->backend, &pl); + } + + currency_hash = g_hash_table_lookup(db->commodity_hash, c); + if(!currency_hash) return NULL; + + lookup_helper.return_list = &result; + lookup_helper.time = t; + g_hash_table_foreach(currency_hash, lookup_nearest, &lookup_helper); + + if(!result) return NULL; + + result = g_list_sort(result, compare_prices_by_date); + + LEAVE (" "); + return result; +} + /* ==================================================================== */ /* gnc_pricedb_foreach_price infrastructure */ diff --git a/src/engine/gnc-pricedb.h b/src/engine/gnc-pricedb.h index b29eb9fce8..45b9a2c0f3 100644 --- a/src/engine/gnc-pricedb.h +++ b/src/engine/gnc-pricedb.h @@ -32,10 +32,12 @@ #include -/**********************************************************************\ - * @file gnc-pricedb.h +/** @addtogroup Engine + @{ */ +/**********************************************************************/ +/** @file gnc-pricedb.h - Introduction: + @brief a simple price database for gnucash The PriceDB is intended to be a database of price quotes, or more specifically, a database of GNCPrices. For the time being, it is @@ -250,8 +252,8 @@ GNCPrice * gnc_pricedb_lookup_latest(GNCPriceDB *db, gnc_commodity *currency); /** gnc_pricedb_lookup_latest_any_currency - find the most recent prices - for the given commodity in any available currency. Returns NULL on - failure. */ + for the given commodity in any available currency. Prices will be + returned as a GNCPrice list (see above). */ GList *gnc_pricedb_lookup_latest_any_currency(GNCPriceDB *db, gnc_commodity *commodity); @@ -270,6 +272,13 @@ GList * gnc_pricedb_lookup_at_time(GNCPriceDB *db, gnc_commodity *currency, Timespec t); +/** gnc_pricedb_lookup_at_time_any_currency - return all prices that match the + given commodity and timespec in any available currency. Prices will be + returned as a GNCPrice list (see above). */ +GList * gnc_pricedb_lookup_at_time_any_currency(GNCPriceDB *db, + gnc_commodity *c, + Timespec t); + /** gnc_pricedb_lookup_day - return all prices that match the given commodity, currency, and timespec. Prices will be returned as a GNCPrice list (see above). */ @@ -278,13 +287,26 @@ GList * gnc_pricedb_lookup_day(GNCPriceDB *db, gnc_commodity *currency, Timespec t); +/** gnc_pricedb_lookup_day_any_currency - return all prices that match the + given commodity and timespec in any available currency. Prices will be + returned as a GNCPrice list (see above). */ +GList * gnc_pricedb_lookup_day_any_currency(GNCPriceDB *db, + gnc_commodity *c, + Timespec t); + /** gnc_pricedb_lookup_nearest_in_time - return the price for the given commodity in the given currency nearest to the given time t. */ -GNCPrice * -gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db, - gnc_commodity *c, - gnc_commodity *currency, - Timespec t); +GNCPrice * gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db, + gnc_commodity *c, + gnc_commodity *currency, + Timespec t); + +/** gnc_pricedb_lookup_nearest_in_time_any_currency - return all prices that + match the given commodity and timespec in any available currency. Prices + will be returned as a GNCPrice list (see above). */ +GList * gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db, + gnc_commodity *c, + Timespec t); /** gnc_pricedb_foreach_price - call f once for each price in db, until and unless f returns FALSE. If stable_order is not FALSE, make @@ -312,3 +334,4 @@ void gnc_price_print(GNCPrice *db, FILE *f, int indent); void gnc_pricedb_print_contents(GNCPriceDB *db, FILE *f); #endif +/** @} */ diff --git a/src/engine/guid.c b/src/engine/guid.c index 2dfefe3c26..4fd8ac36fe 100644 --- a/src/engine/guid.c +++ b/src/engine/guid.c @@ -186,7 +186,7 @@ init_from_dir(const char *dirname, unsigned int max_files) result = snprintf(filename, sizeof(filename), "%s/%s", dirname, de->d_name); - if ((result < 0) || (result >= sizeof(filename))) + if ((result < 0) || (result >= (int)sizeof(filename))) continue; if (stat(filename, &stats) != 0) @@ -548,7 +548,7 @@ guid_hash_to_guint (gconstpointer ptr) else { guint hash = 0; - int i, j; + unsigned int i, j; for (i = 0, j = 0; i < sizeof(guint); i++, j++) { if (j == 16) j = 0; diff --git a/src/engine/test/test-commodities.c b/src/engine/test/test-commodities.c index 8619436760..6889a77cb4 100644 --- a/src/engine/test/test-commodities.c +++ b/src/engine/test/test-commodities.c @@ -123,7 +123,7 @@ test_commodity(void) "insert test"); do_test_args( - gnc_commodity_table_get_size(tbl) == i + 1, + (int)gnc_commodity_table_get_size(tbl) == i + 1, "test next size table", __FILE__, __LINE__, "should be %d and is %d", i + 1, gnc_commodity_table_get_size(tbl)); diff --git a/src/gnome-utils/dialog-options.c b/src/gnome-utils/dialog-options.c index fc1272c004..dc54c3b141 100644 --- a/src/gnome-utils/dialog-options.c +++ b/src/gnome-utils/dialog-options.c @@ -1165,7 +1165,8 @@ gnc_build_options_dialog_contents(GNCOptionWin *propertybox, gint default_page = -1; gint num_sections; gint page; - gint i, j; + gint i; + guint j; g_return_if_fail (propertybox != NULL); g_return_if_fail (odb != NULL); diff --git a/src/gnome-utils/dialog-utils.c b/src/gnome-utils/dialog-utils.c index 9049602524..5d30a3e1b4 100644 --- a/src/gnome-utils/dialog-utils.c +++ b/src/gnome-utils/dialog-utils.c @@ -518,7 +518,7 @@ gnc_option_menu_init(GtkWidget * w) { GtkWidget * menu; GtkWidget * active; - int i; + unsigned int i; menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(w)); @@ -1115,13 +1115,14 @@ gnc_glade_autoconnect_full_func(const gchar *handler_name, gpointer user_data) { GtkSignalFunc func; + GtkSignalFunc *p_func = &func; if (allsymbols == NULL) { /* get a handle on the main executable -- use this to find symbols */ allsymbols = g_module_open(NULL, 0); } - if (!g_module_symbol(allsymbols, handler_name, (gpointer *)&func)) { + if (!g_module_symbol(allsymbols, handler_name, (gpointer *)p_func)) { g_warning("could not find signal handler '%s'.", handler_name); return; } diff --git a/src/gnome-utils/gnc-dense-cal.c b/src/gnome-utils/gnc-dense-cal.c index 129c984171..85c8317d17 100644 --- a/src/gnome-utils/gnc-dense-cal.c +++ b/src/gnome-utils/gnc-dense-cal.c @@ -308,7 +308,7 @@ gnc_dense_cal_init (GncDenseCal *dcal) /* Deal with the various label sizes. */ { gint i; - guint maxWidth, maxHeight, maxAscent, maxLBearing; + gint maxWidth, maxHeight, maxAscent, maxLBearing; gint lbearing, rbearing, width, ascent, descent; dcal->monthLabelFont = gdk_font_load( LABEL_FONT_NAME ); @@ -754,7 +754,7 @@ gnc_dense_cal_draw_to_buffer( GncDenseCal *dcal ) gdk_visual_get_system()->depth ); black.pixel = gdk_rgb_xpixel_from_rgb(0); for ( i=0; i<12; i++ ) { - gint x,y; + guint x,y; /* these are going to be rotated, so transpose width * and height */ dcal->monthLabels[i] = @@ -1497,7 +1497,8 @@ gnc_dense_cal_mark( GncDenseCal *dcal, guint size, GDate **dateArray, gchar *name, gchar *info ) { - gint i, doc; + guint i; + gint doc; gdc_mark_data *newMark; GDate *d; @@ -1547,7 +1548,7 @@ gnc_dense_cal_mark_remove( GncDenseCal *dcal, guint markToRemove ) gdc_mark_data *gdcmd; /* Ignore non-realistic marks */ - if ( markToRemove == -1 ) { + if ( (gint)markToRemove == -1 ) { return; } diff --git a/src/gnome-utils/gnc-frequency.c b/src/gnome-utils/gnc-frequency.c index a6e3512f4d..c08f2ef294 100644 --- a/src/gnome-utils/gnc-frequency.c +++ b/src/gnome-utils/gnc-frequency.c @@ -564,7 +564,7 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outStartDate ) { gint page; struct tm *tmpTm; - guint day; + gint day; GtkWidget *o; UIFreqType uift; FreqSpec *tmpFS; diff --git a/src/gnome-utils/gnc-html.c b/src/gnome-utils/gnc-html.c index b70f38013b..e99faa0e66 100644 --- a/src/gnome-utils/gnc-html.c +++ b/src/gnome-utils/gnc-html.c @@ -444,14 +444,16 @@ gnc_html_http_request_cb(const gchar * uri, int completed_ok, gnc_html * html = user_data; URLType type; char * location = NULL; + char ** p_location = &location; char * label = NULL; GList * handles = NULL; + GList ** p_handles = &handles; GList * current; DEBUG("uri %s, ok %d, body %10.10s, body len %d", uri, completed_ok, body, body_len); g_hash_table_lookup_extended(html->request_info, uri, - (gpointer *)&location, - (gpointer *)&handles); + (gpointer *)p_location, + (gpointer *)p_handles); /* handles will be NULL for an HTTP POST transaction, where we are * displaying the reply data. */ @@ -1388,11 +1390,13 @@ gnc_html_unregister_object_handler(const char * classid) { gchar * keyptr=NULL; gchar * valptr=NULL; + gchar ** p_keyptr = &keyptr; + gchar ** p_valptr = &valptr; if (!g_hash_table_lookup_extended(gnc_html_object_handlers, classid, - (gpointer *)&keyptr, - (gpointer *)&valptr)) + (gpointer *)p_keyptr, + (gpointer *)p_valptr)) return; g_hash_table_remove(gnc_html_object_handlers, classid); @@ -1421,13 +1425,15 @@ gnc_html_unregister_action_handler(const char * actionid) { gchar * keyptr=NULL; gchar * valptr=NULL; + gchar ** p_keyptr = &keyptr; + gchar ** p_valptr = &valptr; g_return_if_fail (actionid != NULL); if (!g_hash_table_lookup_extended(gnc_html_action_handlers, actionid, - (gpointer *)&keyptr, - (gpointer *)&valptr)) + (gpointer *)p_keyptr, + (gpointer *)p_valptr)) return; g_hash_table_remove(gnc_html_action_handlers, actionid); diff --git a/src/gnome/dialog-fincalc.c b/src/gnome/dialog-fincalc.c index 2abc3a6a77..2475998382 100644 --- a/src/gnome/dialog-fincalc.c +++ b/src/gnome/dialog-fincalc.c @@ -341,7 +341,7 @@ can_calc_value(FinCalcDialog *fcd, FinCalcValue value, int *error_item) const char *bad_exp = _("You must enter a valid expression."); const char *string; gnc_numeric nvalue; - int i; + unsigned int i; if (fcd == NULL) return NULL; diff --git a/src/gnome/dialog-scheduledxaction.c b/src/gnome/dialog-scheduledxaction.c index 832a88dc9b..a499b04365 100644 --- a/src/gnome/dialog-scheduledxaction.c +++ b/src/gnome/dialog-scheduledxaction.c @@ -1796,14 +1796,15 @@ delete_button_clicked( GtkButton *b, gpointer d ) book = gnc_get_current_book (); sxList = gnc_book_get_schedxactions( book ); for ( sel = cl->selection; sel; sel = sel->next ) { - guint tag; + gint tag; + gint *p_tag = &tag; gpointer unused; gboolean foundP; sx = (SchedXaction*)gtk_clist_get_row_data( cl, (int)sel->data ); sxList = g_list_remove( sxList, (gpointer)sx ); foundP = g_hash_table_lookup_extended( sxd->sxData, sx, - &unused, (gpointer*)&tag ); + &unused, (gpointer*)p_tag ); g_assert( foundP ); if ( tag != -1 ) { gnc_dense_cal_mark_remove( sxd->gdcal, tag ); @@ -1914,7 +1915,8 @@ putSchedXactionInDialog( gpointer data, gpointer user_data ) int instArraySize; GDate **instArray; GList *instList; - guint gdcMarkTag, oldMarkTag; + gint gdcMarkTag, oldMarkTag; + gint *p_oldMarkTag = &oldMarkTag; sx = (SchedXaction*)data; sxd = (SchedXactionDialog*)user_data; @@ -1998,7 +2000,7 @@ putSchedXactionInDialog( gpointer data, gpointer user_data ) g_hash_table_lookup_extended( sxd->sxData, (gpointer)sx, &unused, - (gpointer*)&oldMarkTag ); + (gpointer*)p_oldMarkTag ); g_assert( foundP ); } if ( row == -1 ) { diff --git a/src/gnome/dialog-sx-from-trans.c b/src/gnome/dialog-sx-from-trans.c index 1f4dd2b49d..947f7b3c64 100644 --- a/src/gnome/dialog-sx-from-trans.c +++ b/src/gnome/dialog-sx-from-trans.c @@ -685,7 +685,7 @@ sxftd_update_example_cal( SXFromTransInfo *sxfti ) struct tm *tmpTm; time_t tmp_tt; GDate date, startDate; - int i; + unsigned int i; FreqSpec *fs; getEndTuple get; gchar *name; diff --git a/src/gnome/gnc-split-reg.h b/src/gnome/gnc-split-reg.h index 8086e35574..7e0d6849f8 100644 --- a/src/gnome/gnc-split-reg.h +++ b/src/gnome/gnc-split-reg.h @@ -125,7 +125,7 @@ struct _GNCSplitReg { gint createFlags; gint disallowedCaps; - gint sort_type; + guint sort_type; gboolean read_only; }; diff --git a/src/gnome/reconcile-list.h b/src/gnome/reconcile-list.h index 9e3f8e7cc1..86d9dc0eb3 100644 --- a/src/gnome/reconcile-list.h +++ b/src/gnome/reconcile-list.h @@ -71,7 +71,7 @@ struct _GNCReconcileList GNCReconcileList *sibling; /* Sorting info */ - gint key; + guint key; gboolean increasing; GtkWidget *title_arrow[5]; diff --git a/src/import-export/import-account-matcher.c b/src/import-export/import-account-matcher.c index cd76d2f64b..142a5f966f 100644 --- a/src/import-export/import-account-matcher.c +++ b/src/import-export/import-account-matcher.c @@ -81,7 +81,7 @@ static gboolean acct_tree_add_accts(struct _accountpickerdialog * picker, Accoun { GtkCTreeNode * node; Account *current_acct; - guint i; + gint i; gboolean expand_parent = FALSE; gboolean expand; gchar * acctinfo[NUM_COLUMNS_CLIST]; diff --git a/src/network-utils/gnc-gpg.c b/src/network-utils/gnc-gpg.c index f66692b294..4a2d5ae027 100644 --- a/src/network-utils/gnc-gpg.c +++ b/src/network-utils/gnc-gpg.c @@ -100,7 +100,7 @@ gnc_gpg_transform_async(const gchar * input, gint input_size, /* parent process. write passphrase to pipe first. */ if(passphrase) { total_bytes = 0; - while(total_bytes < strlen(passphrase)) { + while(total_bytes < (int)strlen(passphrase)) { bytes = write(to_child[1], passphrase+total_bytes, strlen(passphrase)-total_bytes); diff --git a/src/register/register-core/formulacell.c b/src/register/register-core/formulacell.c index da506a0d76..e9919fac55 100644 --- a/src/register/register-core/formulacell.c +++ b/src/register/register-core/formulacell.c @@ -127,8 +127,8 @@ gnc_formula_cell_modify_verify( BasicCell *_cell, FormulaCell *cell = (FormulaCell *)_cell; struct lconv *lc = gnc_localeconv (); const char *toks = "+-*/=()_"; - char decimal_point; - char thousands_sep; + unsigned char decimal_point; + unsigned char thousands_sep; int i; DEBUG( "%s, %d, %s, %d, %d, %d, %d", diff --git a/src/register/register-core/pricecell.c b/src/register/register-core/pricecell.c index e27a7d2400..770263dd3d 100644 --- a/src/register/register-core/pricecell.c +++ b/src/register/register-core/pricecell.c @@ -81,8 +81,8 @@ gnc_price_cell_modify_verify (BasicCell *_cell, PriceCell *cell = (PriceCell *) _cell; struct lconv *lc = gnc_localeconv (); const char *toks = "+-*/=()_"; - char decimal_point; - char thousands_sep; + unsigned char decimal_point; + unsigned char thousands_sep; int i; /* accept the newval string if user action was delete */ diff --git a/src/register/register-gnome/combocell-gnome.c b/src/register/register-gnome/combocell-gnome.c index 02b32e9d52..5bdbe01c36 100644 --- a/src/register/register-gnome/combocell-gnome.c +++ b/src/register/register-gnome/combocell-gnome.c @@ -67,7 +67,7 @@ typedef struct _PopBox gboolean strict; - char complete_char; /* char to be used for auto-completion */ + unsigned char complete_char; /* char to be used for auto-completion */ GList *ignore_strings; } PopBox; diff --git a/src/register/register-gnome/datecell-gnome.c b/src/register/register-gnome/datecell-gnome.c index bc7cefa8cf..7e4645290d 100644 --- a/src/register/register-gnome/datecell-gnome.c +++ b/src/register/register-gnome/datecell-gnome.c @@ -483,7 +483,7 @@ gnc_date_cell_modify_verify (BasicCell *_cell, else { int i, count = 0; - char separator = dateSeparator (); + unsigned char separator = dateSeparator (); gboolean ok = TRUE; for (i = 0; i < change_len; i++) diff --git a/src/register/register-gnome/gnucash-sheet.h b/src/register/register-gnome/gnucash-sheet.h index 27b68ed843..fe37e87d7d 100644 --- a/src/register/register-gnome/gnucash-sheet.h +++ b/src/register/register-gnome/gnucash-sheet.h @@ -105,7 +105,7 @@ typedef struct gint editing; - gint button; /* mouse button being held down */ + guint button; /* mouse button being held down */ gboolean grabbed; /* has the grab */ guint insert_signal;