From 1e5d06d4ceb07ae8ddbd596cb69936fb3807a116 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Fri, 19 May 2000 08:18:29 +0000 Subject: [PATCH] fixed SIZEOF_LONG==4 assumption with ENABLE_MEM_CHECK, from Art Haas Fri May 19 09:00:44 2000 Tim Janik * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with ENABLE_MEM_CHECK, from Art Haas . * gslist.c (g_slist_reverse): shut up compiler. * gscanner.c (g_scanner_get_token_ll): removed inline assignment. * garray.c: remove index>=0 checks for unsigned indices. * gmain.c (g_idle_prepare): timeout assignment fix. * gtree.c (g_tree_node_rotate_right): shut up compiler. --- ChangeLog | 15 +++++++++++++++ ChangeLog.pre-2-0 | 15 +++++++++++++++ ChangeLog.pre-2-10 | 15 +++++++++++++++ ChangeLog.pre-2-12 | 15 +++++++++++++++ ChangeLog.pre-2-2 | 15 +++++++++++++++ ChangeLog.pre-2-4 | 15 +++++++++++++++ ChangeLog.pre-2-6 | 15 +++++++++++++++ ChangeLog.pre-2-8 | 15 +++++++++++++++ garray.c | 14 +++++++------- gcompletion.c | 2 +- glib/garray.c | 14 +++++++------- glib/gcompletion.c | 2 +- glib/gmain.c | 3 ++- glib/gmem.c | 6 +++--- glib/gscanner.c | 7 +++---- glib/gslist.c | 4 ++-- glib/gtree.c | 2 -- gmain.c | 3 ++- gmem.c | 6 +++--- gscanner.c | 7 +++---- gslist.c | 4 ++-- gtree.c | 2 -- testgdate.c | 7 ++----- tests/testgdate.c | 7 ++----- 24 files changed, 160 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42d36dbd9..1dd862e1f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Fri May 19 09:00:44 2000 Tim Janik + + * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with + ENABLE_MEM_CHECK, from Art Haas . + + * gslist.c (g_slist_reverse): shut up compiler. + + * gscanner.c (g_scanner_get_token_ll): removed inline assignment. + + * garray.c: remove index>=0 checks for unsigned indices. + + * gmain.c (g_idle_prepare): timeout assignment fix. + + * gtree.c (g_tree_node_rotate_right): shut up compiler. + 2000-05-13 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 42d36dbd9..1dd862e1f 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,18 @@ +Fri May 19 09:00:44 2000 Tim Janik + + * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with + ENABLE_MEM_CHECK, from Art Haas . + + * gslist.c (g_slist_reverse): shut up compiler. + + * gscanner.c (g_scanner_get_token_ll): removed inline assignment. + + * garray.c: remove index>=0 checks for unsigned indices. + + * gmain.c (g_idle_prepare): timeout assignment fix. + + * gtree.c (g_tree_node_rotate_right): shut up compiler. + 2000-05-13 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 42d36dbd9..1dd862e1f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,18 @@ +Fri May 19 09:00:44 2000 Tim Janik + + * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with + ENABLE_MEM_CHECK, from Art Haas . + + * gslist.c (g_slist_reverse): shut up compiler. + + * gscanner.c (g_scanner_get_token_ll): removed inline assignment. + + * garray.c: remove index>=0 checks for unsigned indices. + + * gmain.c (g_idle_prepare): timeout assignment fix. + + * gtree.c (g_tree_node_rotate_right): shut up compiler. + 2000-05-13 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 42d36dbd9..1dd862e1f 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,18 @@ +Fri May 19 09:00:44 2000 Tim Janik + + * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with + ENABLE_MEM_CHECK, from Art Haas . + + * gslist.c (g_slist_reverse): shut up compiler. + + * gscanner.c (g_scanner_get_token_ll): removed inline assignment. + + * garray.c: remove index>=0 checks for unsigned indices. + + * gmain.c (g_idle_prepare): timeout assignment fix. + + * gtree.c (g_tree_node_rotate_right): shut up compiler. + 2000-05-13 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 42d36dbd9..1dd862e1f 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,18 @@ +Fri May 19 09:00:44 2000 Tim Janik + + * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with + ENABLE_MEM_CHECK, from Art Haas . + + * gslist.c (g_slist_reverse): shut up compiler. + + * gscanner.c (g_scanner_get_token_ll): removed inline assignment. + + * garray.c: remove index>=0 checks for unsigned indices. + + * gmain.c (g_idle_prepare): timeout assignment fix. + + * gtree.c (g_tree_node_rotate_right): shut up compiler. + 2000-05-13 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 42d36dbd9..1dd862e1f 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,18 @@ +Fri May 19 09:00:44 2000 Tim Janik + + * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with + ENABLE_MEM_CHECK, from Art Haas . + + * gslist.c (g_slist_reverse): shut up compiler. + + * gscanner.c (g_scanner_get_token_ll): removed inline assignment. + + * garray.c: remove index>=0 checks for unsigned indices. + + * gmain.c (g_idle_prepare): timeout assignment fix. + + * gtree.c (g_tree_node_rotate_right): shut up compiler. + 2000-05-13 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 42d36dbd9..1dd862e1f 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,18 @@ +Fri May 19 09:00:44 2000 Tim Janik + + * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with + ENABLE_MEM_CHECK, from Art Haas . + + * gslist.c (g_slist_reverse): shut up compiler. + + * gscanner.c (g_scanner_get_token_ll): removed inline assignment. + + * garray.c: remove index>=0 checks for unsigned indices. + + * gmain.c (g_idle_prepare): timeout assignment fix. + + * gtree.c (g_tree_node_rotate_right): shut up compiler. + 2000-05-13 Tor Lillqvist * makefile.mingw.in diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 42d36dbd9..1dd862e1f 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,18 @@ +Fri May 19 09:00:44 2000 Tim Janik + + * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with + ENABLE_MEM_CHECK, from Art Haas . + + * gslist.c (g_slist_reverse): shut up compiler. + + * gscanner.c (g_scanner_get_token_ll): removed inline assignment. + + * garray.c: remove index>=0 checks for unsigned indices. + + * gmain.c (g_idle_prepare): timeout assignment fix. + + * gtree.c (g_tree_node_rotate_right): shut up compiler. + 2000-05-13 Tor Lillqvist * makefile.mingw.in diff --git a/garray.c b/garray.c index e90dcd429..749cd2fe9 100644 --- a/garray.c +++ b/garray.c @@ -209,7 +209,7 @@ g_array_remove_index (GArray* farray, g_return_val_if_fail (array, NULL); - g_return_val_if_fail (index >= 0 && index < array->len, NULL); + g_return_val_if_fail (index < array->len, NULL); if (index != array->len - 1) g_memmove (g_array_elt_pos (array, index), @@ -229,13 +229,13 @@ g_array_remove_index (GArray* farray, GArray* g_array_remove_index_fast (GArray* farray, - guint index) + guint index) { GRealArray* array = (GRealArray*) farray; g_return_val_if_fail (array, NULL); - g_return_val_if_fail (index >= 0 && index < array->len, NULL); + g_return_val_if_fail (index < array->len, NULL); if (index != array->len - 1) g_memmove (g_array_elt_pos (array, index), @@ -403,14 +403,14 @@ g_ptr_array_set_size (GPtrArray *farray, gpointer g_ptr_array_remove_index (GPtrArray* farray, - guint index) + guint index) { GRealPtrArray* array = (GRealPtrArray*) farray; gpointer result; g_return_val_if_fail (array, NULL); - g_return_val_if_fail (index >= 0 && index < array->len, NULL); + g_return_val_if_fail (index < array->len, NULL); result = array->pdata[index]; @@ -429,14 +429,14 @@ g_ptr_array_remove_index (GPtrArray* farray, gpointer g_ptr_array_remove_index_fast (GPtrArray* farray, - guint index) + guint index) { GRealPtrArray* array = (GRealPtrArray*) farray; gpointer result; g_return_val_if_fail (array, NULL); - g_return_val_if_fail (index >= 0 && index < array->len, NULL); + g_return_val_if_fail (index < array->len, NULL); result = array->pdata[index]; diff --git a/gcompletion.c b/gcompletion.c index 68617c1aa..9bc4c9b50 100644 --- a/gcompletion.c +++ b/gcompletion.c @@ -123,7 +123,7 @@ completion_check_cache (GCompletion* cmp, register gint len; register gint i; register gint plen; - gchar* postfix=NULL; + gchar* postfix; gchar* s; if (!new_prefix) diff --git a/glib/garray.c b/glib/garray.c index e90dcd429..749cd2fe9 100644 --- a/glib/garray.c +++ b/glib/garray.c @@ -209,7 +209,7 @@ g_array_remove_index (GArray* farray, g_return_val_if_fail (array, NULL); - g_return_val_if_fail (index >= 0 && index < array->len, NULL); + g_return_val_if_fail (index < array->len, NULL); if (index != array->len - 1) g_memmove (g_array_elt_pos (array, index), @@ -229,13 +229,13 @@ g_array_remove_index (GArray* farray, GArray* g_array_remove_index_fast (GArray* farray, - guint index) + guint index) { GRealArray* array = (GRealArray*) farray; g_return_val_if_fail (array, NULL); - g_return_val_if_fail (index >= 0 && index < array->len, NULL); + g_return_val_if_fail (index < array->len, NULL); if (index != array->len - 1) g_memmove (g_array_elt_pos (array, index), @@ -403,14 +403,14 @@ g_ptr_array_set_size (GPtrArray *farray, gpointer g_ptr_array_remove_index (GPtrArray* farray, - guint index) + guint index) { GRealPtrArray* array = (GRealPtrArray*) farray; gpointer result; g_return_val_if_fail (array, NULL); - g_return_val_if_fail (index >= 0 && index < array->len, NULL); + g_return_val_if_fail (index < array->len, NULL); result = array->pdata[index]; @@ -429,14 +429,14 @@ g_ptr_array_remove_index (GPtrArray* farray, gpointer g_ptr_array_remove_index_fast (GPtrArray* farray, - guint index) + guint index) { GRealPtrArray* array = (GRealPtrArray*) farray; gpointer result; g_return_val_if_fail (array, NULL); - g_return_val_if_fail (index >= 0 && index < array->len, NULL); + g_return_val_if_fail (index < array->len, NULL); result = array->pdata[index]; diff --git a/glib/gcompletion.c b/glib/gcompletion.c index 68617c1aa..9bc4c9b50 100644 --- a/glib/gcompletion.c +++ b/glib/gcompletion.c @@ -123,7 +123,7 @@ completion_check_cache (GCompletion* cmp, register gint len; register gint i; register gint plen; - gchar* postfix=NULL; + gchar* postfix; gchar* s; if (!new_prefix) diff --git a/glib/gmain.c b/glib/gmain.c index e7161c43c..155ccbde0 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -1352,7 +1352,8 @@ g_idle_prepare (gpointer source_data, gint *timeout, gpointer user_data) { - timeout = 0; + *timeout = 0; + return TRUE; } diff --git a/glib/gmem.c b/glib/gmem.c index 4b9dfd97c..41704bce4 100644 --- a/glib/gmem.c +++ b/glib/gmem.c @@ -402,11 +402,11 @@ g_free (gpointer mem) #ifdef ENABLE_MEM_CHECK t = (gulong*) ((guchar*) mem - SIZEOF_LONG); if (*t >= 1) - g_warning ("freeing previously freed memory\n"); + g_warning ("freeing previously freed (%lu times) memory\n", *t); *t += 1; mem = t; - memset ((guchar*) mem + 8, 0, size); + memset ((guchar*) mem + 2 * SIZEOF_LONG, 0, size); #else /* ENABLE_MEM_CHECK */ free (mem); #endif /* ENABLE_MEM_CHECK */ @@ -456,7 +456,7 @@ g_mem_check (gpointer mem) t = (gulong*) ((guchar*) mem - SIZEOF_LONG - SIZEOF_LONG); if (*t >= 1) - g_warning ("mem: 0x%08x has been freed %lu times\n", (gulong) mem, *t); + g_warning ("mem: 0x%08lx has been freed %lu times\n", (gulong) mem, *t); #endif /* ENABLE_MEM_CHECK */ } diff --git a/glib/gscanner.c b/glib/gscanner.c index 55d5fb290..55c311dd2 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -1614,9 +1614,8 @@ g_scanner_get_token_ll (GScanner *scanner, token = G_TOKEN_COMMENT_SINGLE; in_comment_single = TRUE; gstring = g_string_new (""); - while ((ch = g_scanner_get_char (scanner, - line_p, - position_p)) != 0) + ch = g_scanner_get_char (scanner, line_p, position_p); + while (ch != 0) { if (ch == config->cpair_comment_single[1]) { @@ -1626,7 +1625,7 @@ g_scanner_get_token_ll (GScanner *scanner, } gstring = g_string_append_c (gstring, ch); - ch = 0; + ch = g_scanner_get_char (scanner, line_p, position_p); } } else if (config->scan_identifier && ch && diff --git a/glib/gslist.c b/glib/gslist.c index cc8e90607..341d6bd1b 100644 --- a/glib/gslist.c +++ b/glib/gslist.c @@ -390,11 +390,11 @@ GSList* g_slist_reverse (GSList *list) { GSList *prev = NULL; - GSList *next = NULL; while (list) { - next = list->next; + GSList *next = list->next; + list->next = prev; prev = list; diff --git a/glib/gtree.c b/glib/gtree.c index fa40b77e2..229bdf512 100644 --- a/glib/gtree.c +++ b/glib/gtree.c @@ -693,12 +693,10 @@ static GTreeNode* g_tree_node_rotate_right (GTreeNode *node) { GTreeNode *left; - GTreeNode *right; gint a_bal; gint b_bal; left = node->left; - right = node->right; node->left = left->right; left->right = node; diff --git a/gmain.c b/gmain.c index e7161c43c..155ccbde0 100644 --- a/gmain.c +++ b/gmain.c @@ -1352,7 +1352,8 @@ g_idle_prepare (gpointer source_data, gint *timeout, gpointer user_data) { - timeout = 0; + *timeout = 0; + return TRUE; } diff --git a/gmem.c b/gmem.c index 4b9dfd97c..41704bce4 100644 --- a/gmem.c +++ b/gmem.c @@ -402,11 +402,11 @@ g_free (gpointer mem) #ifdef ENABLE_MEM_CHECK t = (gulong*) ((guchar*) mem - SIZEOF_LONG); if (*t >= 1) - g_warning ("freeing previously freed memory\n"); + g_warning ("freeing previously freed (%lu times) memory\n", *t); *t += 1; mem = t; - memset ((guchar*) mem + 8, 0, size); + memset ((guchar*) mem + 2 * SIZEOF_LONG, 0, size); #else /* ENABLE_MEM_CHECK */ free (mem); #endif /* ENABLE_MEM_CHECK */ @@ -456,7 +456,7 @@ g_mem_check (gpointer mem) t = (gulong*) ((guchar*) mem - SIZEOF_LONG - SIZEOF_LONG); if (*t >= 1) - g_warning ("mem: 0x%08x has been freed %lu times\n", (gulong) mem, *t); + g_warning ("mem: 0x%08lx has been freed %lu times\n", (gulong) mem, *t); #endif /* ENABLE_MEM_CHECK */ } diff --git a/gscanner.c b/gscanner.c index 55d5fb290..55c311dd2 100644 --- a/gscanner.c +++ b/gscanner.c @@ -1614,9 +1614,8 @@ g_scanner_get_token_ll (GScanner *scanner, token = G_TOKEN_COMMENT_SINGLE; in_comment_single = TRUE; gstring = g_string_new (""); - while ((ch = g_scanner_get_char (scanner, - line_p, - position_p)) != 0) + ch = g_scanner_get_char (scanner, line_p, position_p); + while (ch != 0) { if (ch == config->cpair_comment_single[1]) { @@ -1626,7 +1625,7 @@ g_scanner_get_token_ll (GScanner *scanner, } gstring = g_string_append_c (gstring, ch); - ch = 0; + ch = g_scanner_get_char (scanner, line_p, position_p); } } else if (config->scan_identifier && ch && diff --git a/gslist.c b/gslist.c index cc8e90607..341d6bd1b 100644 --- a/gslist.c +++ b/gslist.c @@ -390,11 +390,11 @@ GSList* g_slist_reverse (GSList *list) { GSList *prev = NULL; - GSList *next = NULL; while (list) { - next = list->next; + GSList *next = list->next; + list->next = prev; prev = list; diff --git a/gtree.c b/gtree.c index fa40b77e2..229bdf512 100644 --- a/gtree.c +++ b/gtree.c @@ -693,12 +693,10 @@ static GTreeNode* g_tree_node_rotate_right (GTreeNode *node) { GTreeNode *left; - GTreeNode *right; gint a_bal; gint b_bal; left = node->left; - right = node->right; node->left = left->right; left->right = node; diff --git a/testgdate.c b/testgdate.c index 25e8b152b..f74e00a3b 100644 --- a/testgdate.c +++ b/testgdate.c @@ -47,7 +47,6 @@ int main(int argc, char** argv) GDateDay day; gchar buf[101]; gchar* loc; - /* Try to get all the leap year cases. */ GDateYear check_years[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, @@ -63,11 +62,9 @@ int main(int argc, char** argv) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 3000, 3001, 3002, 3998, 3999, 4000, 4001, 4002, 4003 }; - guint n_check_years = sizeof(check_years)/sizeof(GDateYear); - - guint i = 0; - gboolean discontinuity = FALSE; + guint i; + gboolean discontinuity; g_print("checking GDate..."); diff --git a/tests/testgdate.c b/tests/testgdate.c index 25e8b152b..f74e00a3b 100644 --- a/tests/testgdate.c +++ b/tests/testgdate.c @@ -47,7 +47,6 @@ int main(int argc, char** argv) GDateDay day; gchar buf[101]; gchar* loc; - /* Try to get all the leap year cases. */ GDateYear check_years[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, @@ -63,11 +62,9 @@ int main(int argc, char** argv) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 3000, 3001, 3002, 3998, 3999, 4000, 4001, 4002, 4003 }; - guint n_check_years = sizeof(check_years)/sizeof(GDateYear); - - guint i = 0; - gboolean discontinuity = FALSE; + guint i; + gboolean discontinuity; g_print("checking GDate...");