qulogic/libgnt

Remove extra casts in foreach functions.

2019-04-26, Elliott Sales de Andrade
58597d0d6cc3
Parents 6ceba5033150
Children b96ae76fb660
Remove extra casts in foreach functions.

Cast the call to foreach() instead of every argument in the function.
  • +4 -7
    gntbindable.c
  • +2 -3
    gntkeys.c
  • +2 -3
    gntutils.c
  • +16 -18
    gntwm.c
  • +2 -3
    gntws.c
  • --- a/gntbindable.c Fri Apr 26 19:05:22 2019 -0400
    +++ b/gntbindable.c Fri Apr 26 19:21:59 2019 -0400
    @@ -182,10 +182,8 @@
    }
    static void
    -add_binding(gpointer key, gpointer value, gpointer data)
    +add_binding(const gchar *key, GntBindableActionParam *act, BindingView *bv)
    {
    - BindingView *bv = data;
    - GntBindableActionParam *act = value;
    const char *name = g_hash_table_lookup(bv->hash, act->action);
    if (name && *name) {
    const char *k = gnt_key_lookup(key);
    @@ -197,9 +195,8 @@
    }
    static void
    -add_action(gpointer key, gpointer value, gpointer data)
    +add_action(gpointer key, gpointer value, BindingView *bv)
    {
    - BindingView *bv = data;
    g_hash_table_insert(bv->hash, value, key);
    }
    @@ -444,8 +441,8 @@
    BindingView bv = {hash, GNT_TREE(tree)};
    gnt_tree_set_compare_func(bv.tree, (GCompareFunc)g_utf8_collate);
    - g_hash_table_foreach(klass->actions, add_action, &bv);
    - g_hash_table_foreach(klass->bindings, add_binding, &bv);
    + g_hash_table_foreach(klass->actions, (GHFunc)add_action, &bv);
    + g_hash_table_foreach(klass->bindings, (GHFunc)add_binding, &bv);
    if (gnt_tree_get_rows(GNT_TREE(tree)) == NULL) {
    gnt_widget_destroy(GNT_WIDGET(tree));
    tree = NULL;
    --- a/gntkeys.c Fri Apr 26 19:05:22 2019 -0400
    +++ b/gntkeys.c Fri Apr 26 19:21:59 2019 -0400
    @@ -185,9 +185,8 @@
    } gntkey;
    static void
    -get_key_name(gpointer key, gpointer value, gpointer data)
    +get_key_name(gpointer key, const gchar *value, gntkey *k)
    {
    - gntkey *k = data;
    if (k->name)
    return;
    if (g_utf8_collate(value, k->key) == 0)
    @@ -197,7 +196,7 @@
    const char *gnt_key_lookup(const char *key)
    {
    gntkey k = {NULL, key};
    - g_hash_table_foreach(specials, get_key_name, &k);
    + g_hash_table_foreach(specials, (GHFunc)get_key_name, &k);
    return k.name;
    }
    --- a/gntutils.c Fri Apr 26 19:05:22 2019 -0400
    +++ b/gntutils.c Fri Apr 26 19:21:59 2019 -0400
    @@ -152,9 +152,8 @@
    };
    static void
    -duplicate_values(gpointer key, gpointer value, gpointer data)
    +duplicate_values(gpointer key, gpointer value, struct duplicate_fns *fns)
    {
    - struct duplicate_fns *fns = data;
    g_hash_table_insert(fns->table, fns->key_dup ? fns->key_dup(key) : key,
    fns->value_dup ? fns->value_dup(value) : value);
    }
    @@ -165,7 +164,7 @@
    {
    GHashTable *dest = g_hash_table_new_full(hash, equal, key_d, value_d);
    struct duplicate_fns fns = {key_dup, value_dup, dest};
    - g_hash_table_foreach(src, duplicate_values, &fns);
    + g_hash_table_foreach(src, (GHFunc)duplicate_values, &fns);
    return dest;
    }
    --- a/gntwm.c Fri Apr 26 19:05:22 2019 -0400
    +++ b/gntwm.c Fri Apr 26 19:21:59 2019 -0400
    @@ -1176,13 +1176,13 @@
    return TRUE;
    }
    -static void remove_tag(gpointer wid, gpointer wim)
    +static void
    +remove_tag(GntWidget *widget, GntWM *wm)
    {
    - GntWM *wm = GNT_WM(wim);
    - GntWidget *w = GNT_WIDGET(wid);
    - wm->tagged = g_list_remove(wm->tagged, w);
    - mvwhline(w->window, 0, 1, ACS_HLINE | gnt_color_pair(GNT_COLOR_NORMAL), 3);
    - gnt_widget_draw(w);
    + wm->tagged = g_list_remove(wm->tagged, widget);
    + mvwhline(widget->window, 0, 1,
    + ACS_HLINE | gnt_color_pair(GNT_COLOR_NORMAL), 3);
    + gnt_widget_draw(widget);
    }
    static gboolean
    @@ -1209,18 +1209,17 @@
    }
    static void
    -widget_move_ws(gpointer wid, gpointer w)
    +widget_move_ws(GntWidget *wid, GntWM *wm)
    {
    - GntWM *wm = GNT_WM(w);
    - gnt_wm_widget_move_workspace(wm, wm->cws, GNT_WIDGET(wid));
    + gnt_wm_widget_move_workspace(wm, wm->cws, wid);
    }
    static gboolean
    place_tagged(GntBindable *b, G_GNUC_UNUSED GList *params)
    {
    GntWM *wm = GNT_WM(b);
    - g_list_foreach(wm->tagged, widget_move_ws, wm);
    - g_list_foreach(wm->tagged, remove_tag, wm);
    + g_list_foreach(wm->tagged, (GFunc)widget_move_ws, wm);
    + g_list_foreach(wm->tagged, (GFunc)remove_tag, wm);
    g_list_free(wm->tagged);
    wm->tagged = NULL;
    return TRUE;
    @@ -1387,11 +1386,11 @@
    }
    static void
    -accumulate_windows(gpointer window, G_GNUC_UNUSED gpointer node, gpointer p)
    +accumulate_windows(GntWidget *window, G_GNUC_UNUSED gpointer node, GList **p)
    {
    - GList *list = *(GList**)p;
    + GList *list = *p;
    list = g_list_prepend(list, window);
    - *(GList**)p = list;
    + *p = list;
    }
    static void
    @@ -1399,7 +1398,7 @@
    {
    GntWM *wm = GNT_WM(obj);
    GList *list = NULL;
    - g_hash_table_foreach(wm->nodes, accumulate_windows, &list);
    + g_hash_table_foreach(wm->nodes, (GHFunc)accumulate_windows, &list);
    g_list_free_full(list, (GDestroyNotify)gnt_widget_destroy);
    g_hash_table_destroy(wm->nodes);
    wm->nodes = NULL;
    @@ -2089,9 +2088,8 @@
    }
    static void
    -write_gdi(gpointer key, gpointer value, gpointer data)
    +write_gdi(gpointer key, GntPosition *p, gpointer data)
    {
    - GntPosition *p = value;
    fprintf(data, ".%s = %d;%d\n", (char *)key, p->x, p->y);
    }
    @@ -2109,7 +2107,7 @@
    gnt_warning("error opening file (%s) to save positions", filename);
    } else {
    fprintf(file, "[positions]\n");
    - g_hash_table_foreach(wm->positions, write_gdi, file);
    + g_hash_table_foreach(wm->positions, (GHFunc)write_gdi, file);
    fclose(file);
    }
    --- a/gntws.c Fri Apr 26 19:05:22 2019 -0400
    +++ b/gntws.c Fri Apr 26 19:21:59 2019 -0400
    @@ -42,9 +42,8 @@
    * Helpers
    *****************************************************************************/
    static void
    -widget_hide(gpointer data, gpointer nodes)
    +widget_hide(GntWidget *widget, GHashTable *nodes)
    {
    - GntWidget *widget = GNT_WIDGET(data);
    GntNode *node = g_hash_table_lookup(nodes, widget);
    if (GNT_IS_WINDOW(widget))
    gnt_window_workspace_hiding(GNT_WINDOW(widget));
    @@ -193,7 +192,7 @@
    g_return_if_fail(GNT_IS_WS(ws));
    priv = gnt_ws_get_instance_private(ws);
    - g_list_foreach(priv->ordered, widget_hide, nodes);
    + g_list_foreach(priv->ordered, (GFunc)widget_hide, nodes);
    }
    void gnt_ws_widget_hide(GntWidget *widget, GHashTable *nodes)