mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
param: make command sinks (fail/success) return a special type.
These routines free the 'struct command': a common coding error is not to return immediately. To catch this, we make them return a non-NULL 'struct command_result *', and we're going to make the command handlers return the same (to encourage 'return command_fail(...)'-style usage). We also provide two sources for external use: 1. command_param_failed() when param() fails. 2. command_its_complicated() for some complex cases. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -22,13 +22,15 @@ static bool check_fail(void) {
|
||||
|
||||
struct command *cmd;
|
||||
|
||||
void command_fail(struct command *cmd, int code, const char *fmt, ...)
|
||||
struct command_result *command_fail(struct command *cmd,
|
||||
int code, const char *fmt, ...)
|
||||
{
|
||||
failed = true;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
fail_msg = tal_vfmt(cmd, fmt, ap);
|
||||
va_end(ap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* AUTOGENERATED MOCKS START */
|
||||
|
||||
Reference in New Issue
Block a user