[Spice-devel] [PATCH spice-gtk 1/4] gio-coroutine: Fix C inheritance

Christophe Fergeau cfergeau at redhat.com
Mon Apr 16 10:03:07 UTC 2018


On Fri, Apr 13, 2018 at 03:49:16PM +0100, Frediano Ziglio wrote:
> GConditionWaitSource should inherit from GSource so GSource
> should be the first field.

Good catch, however what is interesting is why this worked so far
without issues,
GSource is
struct _GSource
{
  /*< private >*/
  gpointer callback_data;
  ...
};

With GSource being opaque, the only thing which could cause issues
was modifying GConditionWaitSource::self.
However, GConditionWaitSource::self is precisely what we use as
callback_data, and anyway the GSource probably sets callback_data after
spice-gtk set GConditiionWaitSource::self. So this ends up all working
even though this is wrong.

Acked-by: Christophe Fergeau <cfergeau at redhat.com> but I'd add more
details to the log

Christophe



> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  src/gio-coroutine.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gio-coroutine.c b/src/gio-coroutine.c
> index c866e15..1322f01 100644
> --- a/src/gio-coroutine.c
> +++ b/src/gio-coroutine.c
> @@ -24,8 +24,8 @@
>  
>  typedef struct _GConditionWaitSource
>  {
> +    GSource parent; // this MUST be the first field
>      GCoroutine *self;
> -    GSource src;
>      GConditionWaitFunc func;
>      gpointer data;
>  } GConditionWaitSource;
> -- 
> 2.14.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180416/d6e873f6/attachment.sig>


More information about the Spice-devel mailing list