[2593] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

Re: [PATCH] Avoid stripping parameters for function calls in window.c

daemon@ATHENA.MIT.EDU (Nelson Elhage)
Mon Aug 9 11:55:28 2010

From: Nelson Elhage <nelhage@MIT.EDU>
To: David Benjamin <davidben@mit.edu>, barnowl-dev@mit.edu
In-Reply-To: <1281229639-14023-1-git-send-email-davidben@mit.edu>
Date: Mon, 09 Aug 2010 11:55:24 -0400

This case appears to be specific to our code, but is this a bug we
should report to either glib or clang, for glib's use?

- Nelson

On Sat,  7 Aug 2010 18:07:19 -0700, David Benjamin <davidben@MIT.EDU> wrote:
> Although glib depends on this cast to work, clang tries to inline
> owl_window_children_foreach and emits a warning. Unfortunately, we still
> depend on this trick to work in general, by depending on glib.
> 
> Reported-By: Anders Kaseorg <andersk@mit.edu>
> ---
>  window.c |   25 ++++++++++++++++++++-----
>  1 files changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/window.c b/window.c
> index 221b42f..802330a 100644
> --- a/window.c
> +++ b/window.c
> @@ -44,6 +44,16 @@ static void _owl_window_unrealize(owl_window *w);
>  static owl_window *cursor_owner;
>  static owl_window *default_cursor;
>  
> +/* clang gets upset about the glib argument chopping hack because it manages to
> + * inline owl_window_children_foreach. user_data should be a pointer to a
> + * FuncOneArg. */
> +typedef void (*FuncOneArg)(void *);
> +static void first_arg_only(gpointer data, gpointer user_data)
> +{
> +  FuncOneArg *func = user_data;
> +  (*func)(data);
> +}
> +
>  G_DEFINE_TYPE (OwlWindow, owl_window, G_TYPE_OBJECT)
>  
>  static void owl_window_class_init (OwlWindowClass *klass)
> @@ -287,7 +297,8 @@ void owl_window_show(owl_window *w)
>  void owl_window_show_all(owl_window *w)
>  {
>    owl_window_show(w);
> -  owl_window_children_foreach(w, (GFunc)owl_window_show, 0);
> +  FuncOneArg ptr = (FuncOneArg)owl_window_show;
> +  owl_window_children_foreach(w, first_arg_only, &ptr);
>  }
>  
>  void owl_window_hide(owl_window *w)
> @@ -336,7 +347,8 @@ static void _owl_window_realize(owl_window *w)
>    /* schedule a repaint */
>    owl_window_dirty(w);
>    /* map the children */
> -  owl_window_children_foreach(w, (GFunc)_owl_window_realize, 0);
> +  FuncOneArg ptr = (FuncOneArg)_owl_window_realize;
> +  owl_window_children_foreach(w, first_arg_only, &ptr);
>  }
>  
>  static void _owl_window_unrealize(owl_window *w)
> @@ -344,7 +356,8 @@ static void _owl_window_unrealize(owl_window *w)
>    if (w->win == NULL)
>      return;
>    /* unmap all the children */
> -  owl_window_children_foreach(w, (GFunc)_owl_window_unrealize, 0);
> +  FuncOneArg ptr = (FuncOneArg)_owl_window_unrealize;
> +  owl_window_children_foreach(w, first_arg_only, &ptr);
>    _owl_window_destroy_curses(w);
>    w->dirty = w->dirty_subtree = 0;
>    /* subwins leave a mess in the parent; dirty it */
> @@ -398,7 +411,8 @@ void owl_window_dirty(owl_window *w)
>  
>  void owl_window_dirty_children(owl_window *w)
>  {
> -  owl_window_children_foreach(w, (GFunc)owl_window_dirty, 0);
> +  FuncOneArg ptr = (FuncOneArg)owl_window_dirty;
> +  owl_window_children_foreach(w, first_arg_only, &ptr);
>  }
>  
>  static void _owl_window_redraw(owl_window *w)
> @@ -421,7 +435,8 @@ static void _owl_window_redraw_subtree(owl_window *w)
>    if (!w->dirty_subtree)
>      return;
>    _owl_window_redraw(w);
> -  owl_window_children_foreach(w, (GFunc)_owl_window_redraw_subtree, 0);
> +  FuncOneArg ptr = (FuncOneArg)_owl_window_redraw_subtree;
> +  owl_window_children_foreach(w, first_arg_only, &ptr);
>    w->dirty_subtree = 0;
>  }
>  
> -- 
> 1.7.2.1.45.gb1c4
> 
> 

home help back first fref pref prev next nref lref last post