Wireshark-dev: Re: [Wireshark-dev] Problems with passing g_free to g_slist_foreach?

From: Richard Sharpe <realrichardsharpe@xxxxxxxxx>
Date: Wed, 17 Mar 2021 13:11:25 -0700
On Tue, Mar 16, 2021 at 9:23 PM Richard Sharpe
<realrichardsharpe@xxxxxxxxx> wrote:
>
> Hi folks,
>
> I have been seeing some compiler errors on CentOS 8 like the following:
>
> -----------------------------------
> /home/rsharpe/src/<some-path>wireshark/epan/packet.c:142:25: error:
> cast between incompatible function types from ‘void (*)(void *)’ to
> ‘void (*)(void *, void *)’ [-Werror=cast-function-type]
>   g_slist_foreach(*list, (GFunc)g_free, NULL);
>                          ^
> cc1: all warnings being treated as errors
> make[2]: *** [epan/CMakeFiles/epan.dir/build.make:687:
> epan/CMakeFiles/epan.dir/packet.c.o] Error 1
> ----------------------------------
>
> The warning is correct because a GFunc takes two arguments, while
> g_free takes only one argument.
>
> How do I avoid the warning/error?
>
> Also, should we fix these things up?

OK, I see that in the latest sources all these seem to have been fixed
up using the same techniques I used on the 2.6.2-based source I was
working with :-)


-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)(传说杜康是酒的发明者)