From c85dd95c12d6ff8e2d4d74dd72a38e3e01dc0cbc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 6 Nov 2024 21:18:36 +1030 Subject: [PATCH] libplugin: tell compiler that plugin_err is like printf. And fix the fallout! Signed-off-by: Rusty Russell --- plugins/bcli.c | 7 ++++--- plugins/bkpr/bookkeeper.c | 12 ++++++------ plugins/libplugin.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/bcli.c b/plugins/bcli.c index b169a74df..9e2f1eff2 100644 --- a/plugins/bcli.c +++ b/plugins/bcli.c @@ -1006,17 +1006,18 @@ static void parse_getnetworkinfo_result(struct plugin *p, const char *buf) if (!result) plugin_err(p, "Invalid response to '%s': '%s'. Can not " "continue without proceeding to sanity checks.", - gather_args(bitcoind, "getnetworkinfo", NULL), buf); + args_string(tmpctx, gather_args(bitcoind, "getnetworkinfo", NULL)), + buf); /* Check that we have a fully-featured `estimatesmartfee`. */ err = json_scan(tmpctx, buf, result, "{version:%,localrelay:%}", JSON_SCAN(json_to_u32, &bitcoind->version), JSON_SCAN(json_to_bool, &tx_relay)); if (err) - plugin_err(p, "%s. Got '%s'. Can not" + plugin_err(p, "%s. Got '%.*s'. Can not" " continue without proceeding to sanity checks.", err, - gather_args(bitcoind, "getnetworkinfo", NULL), buf); + json_tok_full_len(result), json_tok_full(buf, result)); if (bitcoind->version < min_version) plugin_err(p, "Unsupported bitcoind version %"PRIu32", at least" diff --git a/plugins/bkpr/bookkeeper.c b/plugins/bkpr/bookkeeper.c index 78af58c6e..e2a6489ea 100644 --- a/plugins/bkpr/bookkeeper.c +++ b/plugins/bkpr/bookkeeper.c @@ -891,7 +891,7 @@ static struct command_result *listpeerchannels_multi_done(struct command *cmd, db_commit_transaction(db); if (err) - plugin_err(cmd->plugin, err); + plugin_err(cmd->plugin, "%s", err); /* FIXME: multiple currencies */ if (tal_count(balances) > 0) @@ -907,7 +907,7 @@ static struct command_result *listpeerchannels_multi_done(struct command *cmd, bal->debit, &credit_diff, &debit_diff); if (err) - plugin_err(cmd->plugin, err); + plugin_err(cmd->plugin, "%s", err); log_journal_entry(info->acct, info->currency, @@ -1327,7 +1327,7 @@ listpeerchannels_done(struct command *cmd, const char *buf, db_commit_transaction(db); if (err) - plugin_err(cmd->plugin, err); + plugin_err(cmd->plugin, "%s", err); /* FIXME: multiple currencies per account? */ if (tal_count(balances) > 0) @@ -1346,7 +1346,7 @@ listpeerchannels_done(struct command *cmd, const char *buf, bal->debit, &credit_diff, &debit_diff); if (err) - plugin_err(cmd->plugin, err); + plugin_err(cmd->plugin, "%s", err); log_journal_entry(info->acct, info->ev->currency, @@ -1360,7 +1360,7 @@ listpeerchannels_done(struct command *cmd, const char *buf, /* Maybe mark acct as onchain resolved */ err = do_account_close_checks(cmd, info->ev, info->acct); if (err) - plugin_err(cmd->plugin, err); + plugin_err(cmd->plugin, "%s", err); if (info->ev->payment_id && streq(info->ev->tag, mvt_tag_str(INVOICE))) { @@ -1576,7 +1576,7 @@ parse_and_log_chain_move(struct command *cmd, /* Maybe mark acct as onchain resolved */ err = do_account_close_checks(cmd, e, acct); if (err) - plugin_err(cmd->plugin, err); + plugin_err(cmd->plugin, "%s", err); /* Check for invoice desc data, necessary */ if (e->payment_id) { diff --git a/plugins/libplugin.h b/plugins/libplugin.h index b44899bbd..f4dc7d599 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -322,7 +322,7 @@ bool command_deprecated_in_nocmd_ok(struct plugin *plugin, const char *depr_end); /* Call this on fatal error. */ -void NORETURN plugin_err(struct plugin *p, const char *fmt, ...); +void NORETURN PRINTF_FMT(2,3) plugin_err(struct plugin *p, const char *fmt, ...); /* Call this on fatal error. */ void NORETURN plugin_errv(struct plugin *p, const char *fmt, va_list ap);