libplugin: make set callback for options take plugin ptr, check correct type.

I added a plugin arg and was surprised that compile didn't break.
This is because typesafe_cb et al are conditional casts: if the type
isn't as expected it has no effect, but we're passing plugin_option() through
varargs, so everything is accepted!

Add a noop inline to check type, and fix up the two cases where we
used `const char *` instead of `char *`.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-06-06 10:08:53 +09:30
parent 630dba8840
commit aa5c7e763f
7 changed files with 47 additions and 34 deletions

View File

@@ -21,7 +21,7 @@ const char *funder_opt_name(enum funder_opt opt)
abort();
}
char *funding_option(const char *arg, enum funder_opt *opt)
char *funding_option(struct plugin *plugin, const char *arg, enum funder_opt *opt)
{
if (streq(arg, "match"))
*opt = MATCH;