Alex Bennee wrote:
> I was getting core-dumps in both Gtk1 and 2 versions on startup. The back
> trace looked odd and I couldn't catch it until I noticed this warning from
> gcc:
> cc -c -I.. -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API
> -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/X11R6/include
> -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2
> -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  
> -I/usr/include/libxml2   -g   nodes_gui2.cnodes_gui2.c: In function 
> `nodes_gui_update_nodes_display':
> nodes_gui2.c:527: warning: function called through a non-compatible type
> nodes_gui2.c:527: note: if this code is reached, the program will abort

Well, I never got this warning and I think we can agree that the code
worked fine for quite a while with this bug in place. I assume you are
using GCC 3.4? Or which compiler gave you this warning?
 
> So I did this:
> -       G_LIST_FOREACH(list_nodes, (GFunc) update_row, &now);
> +    g_list_foreach(list_nodes, (GFunc) update_row, &now);

Yes, this should work but I want to keep using a macro instead and
fixed the macro definition therefore. Could you please confirm that the
attached patch fixes the problem as well?

> And it stopped crashing. Reviewing the compile logs I see this error is
> all over the place. Has something gone strange with my build setup or have
> the warnings just got lost in the forest of output that is a compile these
> days?

I don't quite see what you refer to with forest. If you use the compiler
flags as in the example above I don't quite see why you would get *any*
warnings at all - except maybe for the miserable iconv() prototpye. The
only kind of warning I personally don't really care about is "unused
parameter" especially because GTK+ and GLib use a lot of generic
prototypes like the GFunc above and very you often need only one of the
parameters.
If people don't report (important) compiler warnings, we cannot fix the
underlying problem. I would assume we are not aware of the problems
resp. warning if there are any. BTW, I think your report fixes the
latest bug report, so thanks a lot. I wouldn't have found the problem
until I have GCC 3.4 installed although it must have been somewhere
there. Nonetheless, I'm not exactly sure why this construct worked 
before and fails to work now. IIRC, it even worked with other compilers
than GCC.

P.S.: I'll also change the macros to use a trailing underscore instead
of a leading one. The underscore was only chosen to prevent warnings
about shadowing a variable.

-- 
Christian
Index: glib-missing.h
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/glib-missing.h,v
retrieving revision 1.13
diff -u -r1.13 glib-missing.h
--- glib-missing.h      9 Jun 2004 18:12:59 -0000       1.13
+++ glib-missing.h      15 Jun 2004 15:26:02 -0000
@@ -64,7 +64,7 @@
                GList *_l = (list); \
                gpointer _user_data = (user_data); \
                while (NULL != _l) { \
-                       (*(func))(_l->data, _user_data); \
+                       func(_l->data, _user_data); \
                        _l = g_list_next(_l); \
                } \
        } while(0)
@@ -74,7 +74,7 @@
                GList *_l = (list); \
                gpointer _user_data = (user_data); \
                while (NULL != _l) { \
-                       (*(func))(_user_data, _l->data); \
+                       func(_user_data, _l->data); \
                        _l = g_list_next(_l); \
                } \
        } while(0)
@@ -85,7 +85,7 @@
                GSList *_sl = (slist); \
                gpointer _user_data = (user_data); \
                while (NULL != _sl) { \
-                       (*(func))(_sl->data, _user_data); \
+                       func(_sl->data, _user_data); \
                        _sl = g_slist_next(_sl); \
                } \
        } while(0)
@@ -96,7 +96,7 @@
                GSList *_sl = (slist); \
                gpointer _user_data = (user_data); \
                while (NULL != _sl) { \
-                       (*(func))(_user_data, _sl->data); \
+                       func(_user_data, _sl->data); \
                        _sl = g_slist_next(_sl); \
                } \
        } while(0)
Index: nodes_gui2.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/nodes_gui2.c,v
retrieving revision 1.54
diff -u -r1.54 nodes_gui2.c
--- nodes_gui2.c        14 Jun 2004 12:25:36 -0000      1.54
+++ nodes_gui2.c        15 Jun 2004 15:26:11 -0000
@@ -521,7 +521,7 @@
        gtk_tree_view_set_model(treeview_nodes, NULL);
        }
 
-       G_LIST_FOREACH(list_nodes, (GFunc) update_row, &now);
+       G_LIST_FOREACH(list_nodes, update_row, &now);
 
        if (do_freeze) {
        /* "Thaw" view */

Index: search_gui_common.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/search_gui_common.c,v
retrieving revision 1.40
diff -u -r1.40 search_gui_common.c
--- search_gui_common.c 14 Jun 2004 12:00:10 -0000      1.40
+++ search_gui_common.c 15 Jun 2004 15:26:14 -0000
@@ -322,8 +322,9 @@
 
 /* Free all the results_set's of a search */
 
-static void free_r_sets_helper(results_set_t *rs, gpointer user_data)
+static inline void free_r_sets_helper(gpointer data, gpointer user_data)
 {
+       results_set_t *rs = data;
        search_gui_free_r_set(rs);
 }
 
@@ -334,7 +335,7 @@
        g_assert(g_hash_table_size(sch->dups) == 0); /* All records were cleaned */
 
        if (NULL != sch->r_sets) {
-               hash_list_foreach(sch->r_sets, (GFunc) free_r_sets_helper, NULL);
+               hash_list_foreach(sch->r_sets, free_r_sets_helper, NULL);
                hash_list_free(sch->r_sets);
                sch->r_sets = NULL;
        }
Index: uploads_gui2.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/uploads_gui2.c,v
retrieving revision 1.42
diff -u -r1.42 uploads_gui2.c
--- uploads_gui2.c      8 Jun 2004 09:03:23 -0000       1.42
+++ uploads_gui2.c      15 Jun 2004 15:26:14 -0000
@@ -554,12 +554,12 @@
     locked = TRUE;
 
        /* Remove all rows with `removed' uploads. */
-       G_SLIST_FOREACH(sl_removed_uploads, (GFunc) remove_row, &ctx);
+       G_SLIST_FOREACH(sl_removed_uploads, remove_row, &ctx);
        g_slist_free(sl_removed_uploads);
        sl_removed_uploads = ctx.sl_remaining;
 
        /* Update the status column for all active uploads. */ 
-       G_LIST_FOREACH(list_uploads, (GFunc) update_row, &now);
+       G_LIST_FOREACH(list_uploads, update_row, &now);
        
        if (NULL == sl_removed_uploads)
                gtk_widget_set_sensitive(button_uploads_clear_completed, FALSE);
@@ -578,7 +578,7 @@
 
        /* Remove all rows with `removed' uploads. */
 
-       G_SLIST_FOREACH(sl_removed_uploads, (GFunc) remove_row, &ctx);
+       G_SLIST_FOREACH(sl_removed_uploads, remove_row, &ctx);
        g_slist_free(sl_removed_uploads);
        sl_removed_uploads = ctx.sl_remaining;
 
@@ -632,10 +632,10 @@
 
        g_hash_table_destroy(upload_handles);
        upload_handles = NULL;
-       G_LIST_FOREACH(list_uploads, (GFunc) free_row_data, NULL);
+       G_LIST_FOREACH(list_uploads, free_row_data, NULL);
        g_list_free(list_uploads);
        list_uploads = NULL;
-       G_SLIST_FOREACH(sl_removed_uploads, (GFunc) free_row_data, NULL);
+       G_SLIST_FOREACH(sl_removed_uploads, free_row_data, NULL);
        g_slist_free(sl_removed_uploads);
        sl_removed_uploads = NULL;
 }

Attachment: pgpjlaL99IXoN.pgp
Description: PGP signature

Reply via email to