common: note that command_fail doesn't return NULL.

This suppresses some "may-be-uninitialized" warnings later.  It makes
gcc pickier about how we ignore the result though :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-06-15 06:37:38 +09:30
parent 38fad0f3e4
commit e784345b55
2 changed files with 9 additions and 7 deletions

View File

@ -15,7 +15,7 @@ struct command_result;
/* Caller supplied this: param assumes it can call it. */
struct command_result *command_fail(struct command *cmd, errcode_t code,
const char *fmt, ...)
PRINTF_FMT(3, 4) WARN_UNUSED_RESULT;
PRINTF_FMT(3, 4) WARN_UNUSED_RESULT RETURNS_NONNULL;
/* Convenient wrapper for "paramname: msg: invalid token '.*%s'" */
static inline struct command_result *

View File

@ -298,9 +298,10 @@ const char *param_subcommand(struct command *cmd, const char *buffer,
return subcmd;
/* We really do ignore this. */
if (command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Unknown subcommand '%s'", subcmd))
;
struct command_result *ignore;
ignore = command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Unknown subcommand '%s'", subcmd);
assert(ignore);
return NULL;
}
@ -323,9 +324,10 @@ bool param(struct command *cmd, const char *buffer,
}
if (!param_add(&params, name, required, cbx, arg)) {
/* We really do ignore this return! */
if (command_fail(cmd, PARAM_DEV_ERROR,
"developer error: param_add %s", name))
;
struct command_result *ignore;
ignore = command_fail(cmd, PARAM_DEV_ERROR,
"developer error: param_add %s", name);
assert(ignore);
va_end(ap);
return false;
}