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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2018-05-06 at 12:10 +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.

Can you share an example of the warning. I'm not sure it needs to be in
the log, but I'm curious to see what it looks like.

> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  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,

I don't understand how casting to (GIOFunc) makes sure that the
function is the right type. Do you just mean that gcc 8.x will complain
if you try to cast it to (GIOFunc) and it is not actually a GIOFunc?

> +     * 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);
>  }
>  
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]