Fix incompatible pointer types for GtkItemFactoryCallbacks on gcc-14

Review Request #3282 — Created July 6, 2024 and submitted

Information

pidgin/pidgin
release-2.x.y

Reviewers

The GtkItemFactoryEntry struct callback is of type GtkItemFactoryCallbacks
(aka void ()(void)) but is initialised with GtkItemFactoryCallback1 types
(aka void (
)(void , guint, GtkWidget )).

This is coherent with the gtk-2 documentation:

gtk_item_factory_create_items(..., GtkItemFactoryEntry *entries,...)
entries : an array of GtkItemFactoryEntrys whose callback members must by of
type GtkItemFactoryCallback1

But, under gcc-14, the implicit cast from GtkItemFactoryCallback1 to
GtkItemFactoryCallback triggers an incompatible-pointer-types error (See [gcc-doc]).

An exemple of this error:

pidgin/gtkconv.c:3096:66: error: initialization of 'void (*)(void)' from incompatible pointer type 'void (*)(void *, guint,  GtkWidget *)' {aka 'void (*)(void *, unsigned int,  struct _GtkWidget *)'} [-Wincompatible-pointer-types]
 3096 |         { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb,
      |                                                                  ^~~~~~~~~~~~~~~~
pidgin/gtkconv.c:3096:66: note: (near initialization for 'menu_items[1].callback')

To fix this, explicitely cast to GtkItemFactoryCallback where needed.

Built with gcc-14, started and clicked on some affected menus

Summary ID
Fix incompatible pointer types for GtkItemFactoryCallbacks on gcc-14
The GtkItemFactoryEntry struct callback is of type GtkItemFactoryCallbacks (aka void (*)(void)) but is initialised with GtkItemFactoryCallback1 types (aka void (*)(void *, guint, GtkWidget *)). This is coherent with the gtk-2 documentation: > gtk_item_factory_create_items(..., GtkItemFactoryEntry *entries,...) > entries : an array of GtkItemFactoryEntrys whose callback members must by of > type GtkItemFactoryCallback1 But, under gcc-14, the implicit cast from GtkItemFactoryCallback1 to GtkItemFactoryCallback triggers an incompatible-pointer-types error (See [0]). An exemple of this error: pidgin/gtkconv.c:3096:66: error: initialization of 'void (*)(void)' from incompatible pointer type 'void (*)(void *, guint, GtkWidget *)' {aka 'void (*)(void *, unsigned int, struct _GtkWidget *)'} [-Wincompatible-pointer-types] 3096 | { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | ^~~~~~~~~~~~~~~~ pidgin/gtkconv.c:3096:66: note: (near initialization for 'menu_items[1].callback') To fix this, explicitely cast to GtkItemFactoryCallback where needed. Testing Done: Built with gcc-14, started and clicked on some affected menus [0]: https://gcc.gnu.org/gcc-14/porting_to.html#incompatible-pointer-types
06721b86a5a8e6fb8163d9411a7778d2a0274b26
Description From Last Updated

I've found a system where the const is a legitimate part of the type... I need to investiguate...

yoann.congal@smile.fryoann.congal@smile.fr
yoann.congal@smile.fr
  1. 
      
  2. libpurple/xmlnode.c (Diff revision 1)
     
     
    Show all issues

    I've found a system where the const is a legitimate part of the type... I need to investiguate...

    1. const was added in this commit of libxml2 : https://gitlab.gnome.org/GNOME/libxml2/-/commit/61034116d0a3c8b295c6137956adc3ae55720711 in >= v2.12.0

      One of my systems is Debian/testing (with libxml2 at 2.9.14 so without the const)
      The other one (fwiw a Yocto master) has libxml2 at 2.12.7 (with const)

      Having the const is more future-proof, I'll remove its removal from this review.

  3. 
      
yoann.congal@smile.fr
yoann.congal@smile.fr
grim
  1. Nice work and thank you very much!

    How would you like to be credited for this in our COPYRIGHT file?

    1. "Yoann Congal" please :)

      Thanks!

  2. 
      
grim
Review request changed
Status:
Completed