Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

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

From: Richard Sharpe <realrichardsharpe@xxxxxxxxx>
Date: Tue, 16 Mar 2021 21:23:49 -0700
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?

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