gossip: don't use assert around code with side effects.

The use of status_failed() requires a stubs update, which fails
with unnamed parameters, so tweak the status.h header as well.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-12-22 11:40:00 +10:30 committed by Christian Decker
parent 0db821e2cf
commit 047a2ea043
5 changed files with 16 additions and 3 deletions

View File

@ -54,7 +54,7 @@ void status_trace(const char *fmt, ...) PRINTF_FMT(1,2);
/* vprintf-style */
void status_tracev(const char *fmt, va_list ap);
/* Send a failure status code with printf-style msg, and exit. */
void status_failed(enum status_fail, const char *fmt, ...) PRINTF_FMT(2,3) NORETURN;
void status_failed(enum status_fail code, const char *fmt, ...) PRINTF_FMT(2,3) NORETURN;
/* Helper for master failures: sends STATUS_FAIL_MASTER_IO.
* msg NULL == read failure. */

View File

@ -583,8 +583,12 @@ bool handle_channel_announcement(
serialized);
if (forward) {
assert(!queue_broadcast(rstate->broadcasts, WIRE_CHANNEL_ANNOUNCEMENT,
(u8*)tag, serialized));
if (queue_broadcast(rstate->broadcasts,
WIRE_CHANNEL_ANNOUNCEMENT,
(u8*)tag, serialized))
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Announcemnet %s was replaced?",
tal_hex(trc, serialized));
}
tal_free(tmpctx);

View File

@ -69,6 +69,9 @@ bool queue_broadcast(struct broadcast_state *bstate UNNEEDED,
const u8 *tag UNNEEDED,
const u8 *payload UNNEEDED)
{ fprintf(stderr, "queue_broadcast called!\n"); abort(); }
/* Generated stub for status_failed */
void status_failed(enum status_fail code UNNEEDED, const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_pubkey */
void towire_pubkey(u8 **pptr UNNEEDED, const struct pubkey *pubkey UNNEEDED)
{ fprintf(stderr, "towire_pubkey called!\n"); abort(); }

View File

@ -40,6 +40,9 @@ bool queue_broadcast(struct broadcast_state *bstate UNNEEDED,
const u8 *tag UNNEEDED,
const u8 *payload UNNEEDED)
{ fprintf(stderr, "queue_broadcast called!\n"); abort(); }
/* Generated stub for status_failed */
void status_failed(enum status_fail code UNNEEDED, const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_pubkey */
void towire_pubkey(u8 **pptr UNNEEDED, const struct pubkey *pubkey UNNEEDED)
{ fprintf(stderr, "towire_pubkey called!\n"); abort(); }

View File

@ -33,6 +33,9 @@ bool queue_broadcast(struct broadcast_state *bstate UNNEEDED,
const u8 *tag UNNEEDED,
const u8 *payload UNNEEDED)
{ fprintf(stderr, "queue_broadcast called!\n"); abort(); }
/* Generated stub for status_failed */
void status_failed(enum status_fail code UNNEEDED, const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_pubkey */
void towire_pubkey(u8 **pptr UNNEEDED, const struct pubkey *pubkey UNNEEDED)
{ fprintf(stderr, "towire_pubkey called!\n"); abort(); }