Wireshark-dev: Re: [Wireshark-dev] Problems with passing g_free to g_slist_foreach?
From: wsgd <wsgd@xxxxxxx>
Date: Wed, 17 Mar 2021 06:21:22 +0100
Looking at documentation (did not tried) : 
g_slist_free_full(*list, g_free) ?


Regards,
Olivier

Envoyé depuis mon appareil Galaxy


-------- Message d'origine --------
De : Richard Sharpe <realrichardsharpe@xxxxxxxxx>
Date : 17/03/2021 05:27 (GMT+01:00)
À : Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx>
Objet : [Wireshark-dev] Problems with passing g_free to g_slist_foreach?

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
(何以解憂?唯有杜康。--曹操)(传说杜康是酒的发明者)
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe