This version make sure the callback is compatible with the opaque data passed. Also reduce the casts needed by the callbacks. This already fixed a bug in the code. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- server/char-device.c | 10 +++------- server/inputs-channel.c | 3 +-- server/main-channel.c | 4 +--- server/reds.c | 1 + server/reds.h | 8 ++++++++ 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/server/char-device.c b/server/char-device.c index b67e192..f88289c 100644 --- a/server/char-device.c +++ b/server/char-device.c @@ -93,7 +93,7 @@ enum { }; static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer *write_buf); -static void red_char_device_write_retry(void *opaque); +static void red_char_device_write_retry(SpiceCharDeviceState *dev); static RedPipeItem * red_char_device_read_one_msg_from_device(RedCharDevice *dev) @@ -242,10 +242,8 @@ static RedCharDeviceClient *red_char_device_client_find(RedCharDevice *dev, * Reading from the device * **************************/ -static void device_client_wait_for_tokens_timeout(void *opaque) +static void device_client_wait_for_tokens_timeout(RedCharDeviceClient *dev_client) { - RedCharDeviceClient *dev_client = opaque; - red_char_device_handle_client_overflow(dev_client); } @@ -528,10 +526,8 @@ static int red_char_device_write_to_device(RedCharDevice *dev) return total; } -static void red_char_device_write_retry(void *opaque) +static void red_char_device_write_retry(SpiceCharDeviceState *dev) { - RedCharDevice *dev = opaque; - if (dev->priv->write_to_dev_timer) { reds_core_timer_cancel(dev->priv->reds, dev->priv->write_to_dev_timer); } diff --git a/server/inputs-channel.c b/server/inputs-channel.c index 0ce12de..c8b7726 100644 --- a/server/inputs-channel.c +++ b/server/inputs-channel.c @@ -577,9 +577,8 @@ void inputs_channel_on_keyboard_leds_change(InputsChannel *inputs, uint8_t leds) inputs_channel_push_keyboard_modifiers(inputs, leds); } -static void key_modifiers_sender(void *opaque) +static void key_modifiers_sender(InputsChannel *inputs) { - InputsChannel *inputs = opaque; inputs_channel_push_keyboard_modifiers(inputs, kbd_get_leds(inputs_channel_get_keyboard(inputs))); } diff --git a/server/main-channel.c b/server/main-channel.c index 98ce660..c2e1da4 100644 --- a/server/main-channel.c +++ b/server/main-channel.c @@ -1054,10 +1054,8 @@ static void do_ping_client(MainChannelClient *mcc, } } -static void ping_timer_cb(void *opaque) +static void ping_timer_cb(MainChannelClient *mcc) { - MainChannelClient *mcc = opaque; - if (!red_channel_client_is_connected(&mcc->base)) { spice_printerr("not connected to peer, ping off"); reds_core_timer_cancel(mcc->base.channel->reds, mcc->ping_timer); diff --git a/server/reds.c b/server/reds.c index 9898fe5..cbdb20b 100644 --- a/server/reds.c +++ b/server/reds.c @@ -4145,6 +4145,7 @@ void reds_core_watch_remove(RedsState *reds, SpiceWatch *watch) reds->core->watch_remove(watch); } +#undef reds_core_timer_add SpiceTimer *reds_core_timer_add(RedsState *reds, SpiceTimerFunc func, void *opaque) diff --git a/server/reds.h b/server/reds.h index ec1ea59..86e6987 100644 --- a/server/reds.h +++ b/server/reds.h @@ -117,6 +117,14 @@ void reds_core_watch_remove(RedsState *reds, SpiceWatch *watch); SpiceTimer *reds_core_timer_add(RedsState *reds, SpiceTimerFunc func, void *opaque); +#ifdef __GNUC__ +#define reds_core_timer_add(r,f,o) ({ \ + void (*_func)(typeof(o) o) = (f); \ + reds_core_timer_add((r), (SpiceTimerFunc)_func, (o)); }) +#else +#define reds_core_timer_add(r,f,o) \ + reds_core_timer_add((r), (SpiceTimerFunc)(f), (o)) +#endif void reds_core_timer_start(RedsState *reds, SpiceTimer *timer, uint32_t ms); -- 2.7.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel