core-lightning/common/json_command.h
Rusty Russell 819078fe18 param: make command_fail/command_success WARN_UNUSED_RESULT.
This causes a compiler warning if we don't do something with the
result (hopefully return immediately!).

We use was_pending() to ignore the result in the case where we
complete a command in a callback (thus really do want to ignore
the result).

This actually fixes one bug: we didn't return after command_fail
in json_getroute with a bad seed value.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00

27 lines
881 B
C

/* These functions must be supplied by any binary linking with common/param
* so it can fail commands. */
#ifndef LIGHTNING_COMMON_JSON_COMMAND_H
#define LIGHTNING_COMMON_JSON_COMMAND_H
#include "config.h"
#include <ccan/compiler/compiler.h>
#include <stdbool.h>
struct command;
struct command_result;
/* Caller supplied this: param assumes it can call it. */
struct command_result *command_fail(struct command *cmd, int code,
const char *fmt, ...)
PRINTF_FMT(3, 4) WARN_UNUSED_RESULT;
/* Also caller supplied: is this invoked simply to get usage? */
bool command_usage_only(const struct command *cmd);
/* If so, this is called. */
void command_set_usage(struct command *cmd, const char *usage);
/* Also caller supplied: is this invoked simply to check parameters? */
bool command_check_only(const struct command *cmd);
#endif /* LIGHTNING_COMMON_JSON_COMMAND_H */