[Spice-devel] [PATCH spice-server 1/3] event-loop: Avoid possible compiler warning

Christophe Fergeau cfergeau at redhat.com
Tue May 15 12:15:38 UTC 2018


I'm late to the party, but I suspect I would have gone the same way as
in spice-gtk
https://lists.freedesktop.org/archives/spice-devel/2018-May/043324.html
and disabled the warning instead.

Christophe

On Sun, May 06, 2018 at 12:10:31PM +0100, Frediano Ziglio wrote:
> With GCC 8.0.1 (Fedora 28), cast to different function pointer
> can lead to warnings.
> As g_source_set_callback expect a function pointer which type
> changes based on the type of source (so is expected) silent
> the possible warning.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/event-loop.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/server/event-loop.c b/server/event-loop.c
> index 582782e1..d3b7de1b 100644
> --- a/server/event-loop.c
> +++ b/server/event-loop.c
> @@ -143,7 +143,12 @@ static void watch_update_mask(const SpiceCoreInterfaceInternal *iface,
>          return;
>  
>      watch->source = g_io_create_watch(watch->channel, spice_event_to_giocondition(event_mask));
> -    g_source_set_callback(watch->source, (GSourceFunc)watch_func, watch, NULL);
> +    /* g_source_set_callback() documentation says:
> +     * "The exact type of func depends on the type of source; ie. you should
> +     *  not count on func being called with data as its first parameter."
> +     * In this case is a GIOFunc. First cast (GIOFunc) make sure is the right type,
> +     * other casts make possible warning silent */
> +    g_source_set_callback(watch->source, (GSourceFunc)(void*)(GIOFunc)watch_func, watch, NULL);
>      g_source_attach(watch->source, watch->context);
>  }
>  
> -- 
> 2.17.0
> 
> _______________________________________________
> 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/20180515/6fbcc520/attachment.sig>


More information about the Spice-devel mailing list