Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
047a2ea043
  1. 2
      common/status.h
  2. 8
      gossipd/routing.c
  3. 3
      gossipd/test/run-bench-find_route.c
  4. 3
      gossipd/test/run-find_route-specific.c
  5. 3
      gossipd/test/run-find_route.c

2
common/status.h

@ -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. */

8
gossipd/routing.c

@ -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);

3
gossipd/test/run-bench-find_route.c

@ -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(); }

3
gossipd/test/run-find_route-specific.c

@ -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(); }

3
gossipd/test/run-find_route.c

@ -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(); }

Loading…
Cancel
Save