# HG changeset patch # User David Demelier # Date 1633252847 -7200 # Node ID 2c0eea3af7df5e40b82af5b3841830db1ad25c18 # Parent 6c15d37b751899311eec30a27a8cb68e58f316ec misc: be more pedantic diff -r 6c15d37b7518 -r 2c0eea3af7df irccd/dl-plugin.c --- a/irccd/dl-plugin.c Wed Sep 22 15:44:36 2021 +0200 +++ b/irccd/dl-plugin.c Sun Oct 03 11:20:47 2021 +0200 @@ -32,15 +32,46 @@ #include "dl-plugin.h" +/* Invoke with arguments and return value. */ #define INVOKE(pg, name, sig, ...) \ do { \ struct self *self = pg->data; \ sig fn; \ \ - if (self->handle && (fn = dlsym(self->handle, symbol(self, name)))) \ + if (self->handle && (fn = (sig)dlsym(self->handle, symbol(self, name))))\ return fn(__VA_ARGS__); \ } while (0) +/* Invoke with argument and without return value. */ +#define INVOKE_NR(pg, name, sig, ...) \ +do { \ + struct self *self = pg->data; \ + sig fn; \ + \ + if (self->handle && (fn = (sig)dlsym(self->handle, symbol(self, name))))\ + fn(__VA_ARGS__); \ +} while (0) + +/* Invoke without arguments and with return value. */ +#define INVOKE_NA(pg, name, sig) \ +do { \ + struct self *self = pg->data; \ + sig fn; \ + \ + if (self->handle && (fn = (sig)dlsym(self->handle, symbol(self, name))))\ + return fn(); \ +} while (0) + +/* Invoke without arguments and without return value. */ +#define INVOKE_NA_NR(pg, name, sig) \ +do { \ + struct self *self = pg->data; \ + sig fn; \ + \ + if (self->handle && (fn = (sig)dlsym(self->handle, symbol(self, name))))\ + fn(); \ +} while (0) + struct self { struct irc_plugin plugin; char prefix[32]; @@ -85,7 +116,7 @@ static void set_template(struct irc_plugin *plg, const char *key, const char *value) { - INVOKE(plg, "set_template", set_template_fn, key, value); + INVOKE_NR(plg, "set_template", set_template_fn, key, value); } static const char * @@ -99,7 +130,7 @@ static const char ** get_templates(struct irc_plugin *plg) { - INVOKE(plg, "get_templates", get_templates_fn); + INVOKE_NA(plg, "get_templates", get_templates_fn); return NULL; } @@ -107,7 +138,7 @@ static void set_path(struct irc_plugin *plg, const char *key, const char *value) { - INVOKE(plg, "set_path", set_path_fn, key, value); + INVOKE_NR(plg, "set_path", set_path_fn, key, value); } static const char * @@ -121,7 +152,7 @@ static const char ** get_paths(struct irc_plugin *plg) { - INVOKE(plg, "get_paths", get_paths_fn); + INVOKE_NA(plg, "get_paths", get_paths_fn); return NULL; } @@ -129,7 +160,7 @@ static void set_option(struct irc_plugin *plg, const char *key, const char *value) { - INVOKE(plg, "set_option", set_option_fn, key, value); + INVOKE_NR(plg, "set_option", set_option_fn, key, value); } static const char * @@ -143,7 +174,7 @@ static const char ** get_options(struct irc_plugin *plg) { - INVOKE(plg, "get_options", get_options_fn); + INVOKE_NA(plg, "get_options", get_options_fn); return NULL; } @@ -151,7 +182,7 @@ static int load(struct irc_plugin *plg) { - INVOKE(plg, "load", load_fn); + INVOKE_NA(plg, "load", load_fn); return 0; } @@ -159,19 +190,19 @@ static void reload(struct irc_plugin *plg) { - INVOKE(plg, "reload", reload_fn); + INVOKE_NA_NR(plg, "reload", reload_fn); } static void unload(struct irc_plugin *plg) { - INVOKE(plg, "unload", unload_fn); + INVOKE_NA_NR(plg, "unload", unload_fn); } static void handle(struct irc_plugin *plg, const struct irc_event *ev) { - INVOKE(plg, "event", event_fn, ev); + INVOKE_NR(plg, "event", event_fn, ev); } static void diff -r 6c15d37b7518 -r 2c0eea3af7df irccdctl/irccdctl.c --- a/irccdctl/irccdctl.c Wed Sep 22 15:44:36 2021 +0200 +++ b/irccdctl/irccdctl.c Sun Oct 03 11:20:47 2021 +0200 @@ -436,7 +436,7 @@ static void cmd_plugin_config(int argc, char **argv) { - return plugin_list_set(argc, argv, "PLUGIN-CONFIG"); + plugin_list_set(argc, argv, "PLUGIN-CONFIG"); } /* @@ -488,7 +488,7 @@ static void cmd_plugin_path(int argc, char **argv) { - return plugin_list_set(argc, argv, "PLUGIN-PATH"); + plugin_list_set(argc, argv, "PLUGIN-PATH"); } static void @@ -505,7 +505,7 @@ static void cmd_plugin_template(int argc, char **argv) { - return plugin_list_set(argc, argv, "PLUGIN-TEMPLATE"); + plugin_list_set(argc, argv, "PLUGIN-TEMPLATE"); } static void diff -r 6c15d37b7518 -r 2c0eea3af7df tests/test-rule.c --- a/tests/test-rule.c Wed Sep 22 15:44:36 2021 +0200 +++ b/tests/test-rule.c Sun Oct 03 11:20:47 2021 +0200 @@ -163,7 +163,7 @@ irc_rule_add(r32->events, "onCommand"); irc_rule_add(r32->events, "onMessage"); irc_bot_rule_insert(r32, -1); -}; +} GREATEST_TEST solve_match1(void)