[Spice-devel] [spice-gtk 1/3] build-sys: Disable -Wcast-function-type

Christophe Fergeau cfergeau at redhat.com
Thu May 3 15:27:24 UTC 2018


On Thu, May 03, 2018 at 07:37:44AM -0400, Frediano Ziglio wrote:
> > 
> > With gcc 8.0.1 from Fedora 28, I'm getting warnings related to
> > -Wcast-function-type in a few places. Most of these could be solved
> > by adding an intermediate wrapper with the right number of args, but the
> > g_source_set_callback() warning cannot be solved this way as the
> > callback signature will vary depending on the source it's called on.
> > 
> > ../../src/spice-session.c: In function 'spice_session_init':
> > ../../src/spice-session.c:293:33: warning: cast between incompatible function
> > types from 'pixman_bool_t (*)(pixman_image_t *)' {aka 'int (*)(union
> > pixman_image *)'} to 'void (*)(void *)' [-Wcast-function-type]
> >      s->images = cache_image_new((GDestroyNotify)pixman_image_unref);
> >                                  ^
> > ../../src/gio-coroutine.c: In function 'g_coroutine_socket_wait':
> > ../../src/gio-coroutine.c:59:32: warning: cast between incompatible function
> > types from 'gboolean (*)(GSocket *, GIOCondition,  void *)' {aka 'int
> > (*)(struct _GSocket *, enum <anonymous>,  void *)'} to 'gboolean (*)(void
> > *)' {aka 'int (*)(void *)'} [-Wcast-function-type]
> >      g_source_set_callback(src, (GSourceFunc)g_io_wait_helper, self, NULL);
> >                                 ^
> > ../../src/spice-channel.c: In function 'spice_channel_iterate_read':
> > ../../src/spice-channel.c:2342:36: warning: cast between incompatible
> > function types from 'void (*)(SpiceChannel *, SpiceMsgIn *)' {aka 'void
> > (*)(struct _SpiceChannel *, struct _SpiceMsgIn *)'} to 'void
> > (*)(SpiceChannel *, SpiceMsgIn *, void *)' {aka 'void (*)(struct
> > _SpiceChannel *, struct _SpiceMsgIn *, void *)'} [-Wcast-function-type]
> >                                     (handler_msg_in)SPICE_CHANNEL_GET_CLASS(channel)->handle_msg,
> >                                     NULL);
> >                                     ^
> > ../../src/spice-channel.c: In function 'channel_reset':
> > ../../src/spice-channel.c:2838:37: warning: cast between incompatible
> > function types from 'void (*)(SpiceMsgOut *)' {aka 'void (*)(struct
> > _SpiceMsgOut *)'} to 'void (*)(void *, void *)' [-Wcast-function-type]
> >      g_queue_foreach(&c->xmit_queue, (GFunc)spice_msg_out_unref, NULL);
> >                                      ^
> > ../../src/channel-usbredir.c: In function 'try_write_compress_LZ4':
> > ../../src/channel-usbredir.c:714:42: warning: cast between incompatible
> > function types from 'void (*)(void *)' to 'void (*)(uint8_t *, void *)' {aka
> > 'void (*)(unsigned char *, void *)'} [-Wcast-function-type]
> >                                           (spice_marshaller_item_free_func)g_free,
> >                                           ^
> > ../../src/channel-smartcard.c: In function
> > 'spice_smartcard_channel_finalize':
> > ../../src/channel-smartcard.c:167:43: warning: cast between incompatible
> > function types from 'void (*)(SpiceSmartcardChannelMessage *)' {aka 'void
> > (*)(struct _SpiceSmartcardChannelMessage *)'} to 'void (*)(void *, void *)'
> > [-Wcast-function-type]
> >          g_queue_foreach(c->message_queue, (GFunc)smartcard_message_free,
> >          NULL);
> >                                            ^
> > ../../src/channel-smartcard.c: In function 'spice_smartcard_channel_reset':
> > ../../src/channel-smartcard.c:187:43: warning: cast between incompatible
> > function types from 'void (*)(SpiceSmartcardChannelMessage *)' {aka 'void
> > (*)(struct _SpiceSmartcardChannelMessage *)'} to 'void (*)(void *, void *)'
> > [-Wcast-function-type]
> >          g_queue_foreach(c->message_queue, (GFunc)smartcard_message_free,
> >          NULL);
> >                                            ^
> > In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
> >                  from /usr/include/glib-2.0/glib.h:32,
> >                  from /usr/include/glib-2.0/gobject/gbinding.h:28,
> >                  from /usr/include/glib-2.0/glib-object.h:23,
> >                  from ../../src/smartcard-manager.c:20:
> > ../../src/smartcard-manager.c: In function 'spice_smartcard_manager_get':
> > ../../src/smartcard-manager.c:250:19: warning: cast between incompatible
> > function types from 'SpiceSmartcardManager * (*)(void)' {aka 'struct
> > _SpiceSmartcardManager * (*)(void)'} to 'void * (*)(void *)'
> > [-Wcast-function-type]
> >                    (GThreadFunc)spice_smartcard_manager_new,
> >                    ^
> > /usr/include/glib-2.0/glib/gthread.h:243:26: note: in definition of macro
> > 'g_once'
> >     g_once_impl ((once), (func), (arg)))
> >                           ^~~~
> > ../../src/smartcard-manager.c: In function 'smartcard_source_dispatch':
> > ../../src/smartcard-manager.c:333:46: warning: cast between incompatible
> > function types from 'GSourceFunc' {aka 'int (*)(void *)'} to 'gboolean
> > (*)(VEvent *, void *)' {aka 'int (*)(struct VEventStruct *, void *)'}
> > [-Wcast-function-type]
> >      SmartcardSourceFunc smartcard_callback = (SmartcardSourceFunc)callback;
> >                                               ^
> > ../../src/smartcard-manager.c: In function 'smartcard_monitor_add':
> > ../../src/smartcard-manager.c:379:35: warning: cast between incompatible
> > function types from 'SmartcardSourceFunc' {aka 'int (*)(struct VEventStruct
> > *, void *)'} to 'gboolean (*)(void *)' {aka 'int (*)(void *)'}
> > [-Wcast-function-type]
> >      g_source_set_callback(source, (GSourceFunc)callback, user_data, NULL);
> >                                    ^
> > In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
> >                  from /usr/include/glib-2.0/glib.h:32,
> >                  from /usr/include/glib-2.0/gobject/gbinding.h:28,
> >                  from /usr/include/glib-2.0/glib-object.h:23,
> >                  from ../../src/smartcard-manager.c:20:
> > ../../src/smartcard-manager.c: In function 'smartcard_manager_init_helper':
> > ../../src/smartcard-manager.c:484:12: warning: cast between incompatible
> > function types from 'gboolean (*)(SmartcardManagerInitArgs *)' {aka 'int
> > (*)(struct <anonymous> *)'} to 'void * (*)(void *)' [-Wcast-function-type]
> >             (GThreadFunc)smartcard_manager_init,
> >             ^
> > /usr/include/glib-2.0/glib/gthread.h:243:26: note: in definition of macro
> > 'g_once'
> >     g_once_impl ((once), (func), (arg)))
> >                           ^~~~
> > ../../src/usb-device-manager.c: In function 'channel_new':
> > ../../src/usb-device-manager.c:861:42: warning: cast between incompatible
> > function types from 'void (*)(void *)' to 'void (*)(void *, GObject *)' {aka
> > 'void (*)(void *, struct _GObject *)'} [-Wcast-function-type]
> >      g_object_weak_ref(G_OBJECT(channel), (GWeakNotify)g_object_unref, self);
> >                                           ^
> > ../../src/spice-widget.c: In function 'spice_display_get_pixbuf':
> > ../../src/spice-widget.c:3150:40: warning: cast between incompatible function
> > types from 'void (*)(void *)' to 'void (*)(guchar *, void *)' {aka 'void
> > (*)(unsigned char *, void *)'} [-Wcast-function-type]
> >                                         (GdkPixbufDestroyNotify)g_free,
> >                                         NULL);
> >                                         ^
> > ../../src/spice-widget.c:3178:43: warning: cast between incompatible function
> > types from 'void (*)(void *)' to 'void (*)(guchar *, void *)' {aka 'void
> > (*)(unsigned char *, void *)'} [-Wcast-function-type]
> >                                            (GdkPixbufDestroyNotify)g_free,
> >                                            NULL);
> >                                            ^
> 
> Maybe not reporting all warnings but just the head ?

The head? Just the first few warnings? Sure, I can make the commit
log less verbose :)

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180503/505392ac/attachment.sig>


More information about the Spice-devel mailing list