libplugin: use a typesafe_cb for plugin_timer

This commit is contained in:
darosior 2020-02-16 12:31:47 +01:00 committed by Rusty Russell
parent 11149ef5a1
commit e7b0c24db2
2 changed files with 13 additions and 7 deletions

View file

@ -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;

View file

@ -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);