From e7b0c24db20c2efd062be65eaf241768b1517cf5 Mon Sep 17 00:00:00 2001 From: darosior Date: Sun, 16 Feb 2020 12:31:47 +0100 Subject: [PATCH] libplugin: use a typesafe_cb for plugin_timer --- plugins/libplugin.c | 6 +++--- plugins/libplugin.h | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/plugins/libplugin.c b/plugins/libplugin.c index b7c5d06ee..f589b2b7e 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -835,9 +835,9 @@ static void destroy_plugin_timer(struct plugin_timer *timer, struct plugin *p) timer_del(&p->timers, &timer->timer); } -struct plugin_timer *plugin_timer(struct plugin *p, struct timerel t, - void (*cb)(void *cb_arg), - void *cb_arg) +struct plugin_timer *plugin_timer_(struct plugin *p, struct timerel t, + void (*cb)(void *cb_arg), + void *cb_arg) { struct plugin_timer *timer = tal(NULL, struct plugin_timer); timer->cb = cb; diff --git a/plugins/libplugin.h b/plugins/libplugin.h index 6c4343f9d..1d6bdb3b5 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -210,10 +210,16 @@ struct command_result *timer_complete(struct plugin *p); * Freeing this releases the timer, otherwise it's freed after @cb * if it hasn't been freed already. */ -struct plugin_timer *plugin_timer(struct plugin *p, - struct timerel t, - void (*cb)(void *cb_arg), - void *cb_arg); +struct plugin_timer *plugin_timer_(struct plugin *p, + struct timerel t, + void (*cb)(void *cb_arg), + void *cb_arg); + +#define plugin_timer(plugin, time, cb, cb_arg) \ + plugin_timer_((plugin), (time), \ + typesafe_cb(void, void *, \ + (cb), (cb_arg)), \ + (cb_arg)) \ /* Log something */ void plugin_log(struct plugin *p, enum log_level l, const char *fmt, ...) PRINTF_FMT(3, 4);