From: Friedrich Beckmann Date: Sun, 30 Aug 2020 12:56:21 +0000 (+0200) Subject: moved GFunc cast to macro GFUNC_COMPAT_CAST X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1615e16376cf653f1faf105ba098120febdd1cb1;p=pspp moved GFunc cast to macro GFUNC_COMPAT_CAST I moved the GFunc cast for g_list_foreach to a macro with some explaining comment. The macro is in helper.h --- diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h index c1d93a8c03..8d18fcf4b4 100644 --- a/src/ui/gui/helper.h +++ b/src/ui/gui/helper.h @@ -65,5 +65,13 @@ psppire_box_pack_start_defaults (GtkBox *box, GtkWidget *widget) gtk_box_pack_start (box, widget, TRUE, TRUE, 0); } +/* Starting with gcc8 the warning Wcast-function-type will + trigger if no intermediate (void (*)(void)) cast is done + for a function cast to GFunc when the number of parameters + is not 2. The reason is that the compiler behaviour in this + situation is undefined according to C standard although many + implementations rely on this. */ +#define GFUNC_COMPAT_CAST(x) ((GFunc) (void (*)(void)) (x)) + #endif diff --git a/src/ui/gui/psppire-acr.c b/src/ui/gui/psppire-acr.c index 82f9aa2c16..0b397fe3dc 100644 --- a/src/ui/gui/psppire-acr.c +++ b/src/ui/gui/psppire-acr.c @@ -183,7 +183,7 @@ on_change_button_clicked (PsppireAcr *acr) g_value_unset (&value); } - g_list_foreach (l, (GFunc) (void (*)(void)) gtk_tree_path_free, NULL); + g_list_foreach (l, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); g_list_free (l); if (acr->update) acr->update (acr->update_data); @@ -209,7 +209,7 @@ on_remove_button_clicked (PsppireAcr *acr) gtk_list_store_remove (acr->list_store, &iter); - g_list_foreach (l, (GFunc) (void (*)(void)) gtk_tree_path_free, NULL); + g_list_foreach (l, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); g_list_free (l); } @@ -225,7 +225,7 @@ row_is_selected (const PsppireAcr *acr) result = (l != NULL); - g_list_foreach (l, (GFunc) (void (*)(void)) gtk_tree_path_free, NULL); + g_list_foreach (l, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); g_list_free (l); return result; diff --git a/src/ui/gui/psppire-dialog-action-autorecode.c b/src/ui/gui/psppire-dialog-action-autorecode.c index a2ec973984..2f1bdcbecb 100644 --- a/src/ui/gui/psppire-dialog-action-autorecode.c +++ b/src/ui/gui/psppire-dialog-action-autorecode.c @@ -23,6 +23,7 @@ #include #include "psppire-dialog.h" #include "builder-wrapper.h" +#include "helper.h" #include "gettext.h" #define _(msgid) gettext (msgid) @@ -192,7 +193,7 @@ on_change_clicked (GObject *obj, gpointer data) gtk_tree_model_row_changed (model, rows->data, &iter); finish: - g_list_foreach (rows, (GFunc) (void (*)(void)) gtk_tree_path_free, NULL); + g_list_foreach (rows, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); g_list_free (rows); var_unref (var); } @@ -275,7 +276,7 @@ on_selection_change (GtkTreeSelection *selection, gpointer data) gtk_widget_set_sensitive (rd->change_button, FALSE); } - g_list_foreach (rows, (GFunc) (void (*)(void)) gtk_tree_path_free, NULL); + g_list_foreach (rows, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); g_list_free (rows); } diff --git a/src/ui/gui/psppire-dialog-action-recode-different.c b/src/ui/gui/psppire-dialog-action-recode-different.c index 594f8bc9a2..a49d05306e 100644 --- a/src/ui/gui/psppire-dialog-action-recode-different.c +++ b/src/ui/gui/psppire-dialog-action-recode-different.c @@ -208,7 +208,7 @@ on_change_clicked (GObject *obj, gpointer data) gtk_tree_model_row_changed (model, rows->data, &iter); finish: - g_list_foreach (rows, (GFunc) (void (*)(void)) gtk_tree_path_free, NULL); + g_list_foreach (rows, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); g_list_free (rows); } @@ -272,7 +272,7 @@ on_selection_change (GtkTreeSelection *selection, gpointer data) } - g_list_foreach (rows, (GFunc) (void (*)(void)) gtk_tree_path_free, NULL); + g_list_foreach (rows, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); g_list_free (rows); } diff --git a/src/ui/gui/psppire-selector.c b/src/ui/gui/psppire-selector.c index a551573fe9..678c2a749f 100644 --- a/src/ui/gui/psppire-selector.c +++ b/src/ui/gui/psppire-selector.c @@ -62,6 +62,7 @@ #include "psppire-dict.h" #include "psppire-select-dest.h" #include "psppire-means-layer.h" +#include "helper.h" #include @@ -575,7 +576,7 @@ de_select_tree_model (GtkTreeSelection *selection, GtkTreeModel *model) } /* Delete list of RowRefs and its contents */ - g_list_foreach (selected_rows, (GFunc) (void (*)(void)) gtk_tree_row_reference_free, NULL); + g_list_foreach (selected_rows, GFUNC_COMPAT_CAST (gtk_tree_row_reference_free), NULL); g_list_free (selected_rows); } @@ -662,7 +663,7 @@ select_selection (PsppireSelector *selector) ); } - g_list_foreach (selected_rows, (GFunc) (void (*)(void)) gtk_tree_path_free, NULL); + g_list_foreach (selected_rows, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); g_list_free (selected_rows); refilter (selector);