diff --git a/common/memleak.c b/common/memleak.c index cee84b014..7283cd56b 100644 --- a/common/memleak.c +++ b/common/memleak.c @@ -270,4 +270,9 @@ void memleak_cleanup(void) { notleaks = tal_free(notleaks); } -#endif /* DEVELOPER */ +#else /* !DEVELOPER */ +void *notleak_(const void *ptr, bool plus_children UNNEEDED) +{ + return cast_const(void *, ptr); +} +#endif /* !DEVELOPER */ diff --git a/common/memleak.h b/common/memleak.h index df2cced7e..7db95b714 100644 --- a/common/memleak.h +++ b/common/memleak.h @@ -17,7 +17,6 @@ /* Mark a pointer and all its tal children as not being leaked. */ #define notleak_with_children(p) ((memleak_typeof(p))notleak_((p), true)) -#if DEVELOPER void *notleak_(const void *ptr, bool plus_children); struct htable; @@ -53,11 +52,4 @@ void memleak_scan_region(struct htable *memtable, /* Get (and remove) a leak from memtable, or NULL */ const void *memleak_get(struct htable *memtable, const uintptr_t **backtrace); -#else /* ... !DEVELOPER */ -static inline void *notleak_(const void *ptr, bool plus_children UNNEEDED) -{ - return cast_const(void *, ptr); -} -#endif /* !DEVELOPER */ - #endif /* LIGHTNING_COMMON_MEMLEAK_H */ diff --git a/common/subdaemon.h b/common/subdaemon.h index 7e18bc3fa..55265a530 100644 --- a/common/subdaemon.h +++ b/common/subdaemon.h @@ -2,14 +2,12 @@ #define LIGHTNING_COMMON_SUBDAEMON_H #include "config.h" #include +struct htable; /* daemon_setup, but for subdaemons */ void subdaemon_setup(int argc, char *argv[]); -#if DEVELOPER -struct htable; - +/* Only defined if DEVELOPER */ bool dump_memleak(struct htable *memtable); -#endif #endif /* LIGHTNING_COMMON_SUBDAEMON_H */ diff --git a/gossipd/routing.h b/gossipd/routing.h index b886290f0..cce3fac12 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -396,10 +396,8 @@ bool routing_add_node_announcement(struct routing_state *rstate, bool handle_local_add_channel(struct routing_state *rstate, const u8 *msg, u64 index); -#if DEVELOPER void memleak_remove_routing_tables(struct htable *memtable, const struct routing_state *rstate); -#endif /** * Get the local time. diff --git a/gossipd/test/run-crc32_of_update.c b/gossipd/test/run-crc32_of_update.c index fb219b281..322f3fec8 100644 --- a/gossipd/test/run-crc32_of_update.c +++ b/gossipd/test/run-crc32_of_update.c @@ -35,6 +35,9 @@ void daemon_shutdown(void) /* Generated stub for decode_short_ids */ struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *encoded UNNEEDED) { fprintf(stderr, "decode_short_ids called!\n"); abort(); } +/* Generated stub for dump_memleak */ +bool dump_memleak(struct htable *memtable UNNEEDED) +{ fprintf(stderr, "dump_memleak called!\n"); abort(); } /* Generated stub for first_chan */ struct chan *first_chan(const struct node *node UNNEEDED, struct chan_map_iter *i UNNEEDED) { fprintf(stderr, "first_chan called!\n"); abort(); } @@ -186,6 +189,18 @@ u8 *make_ping(const tal_t *ctx UNNEEDED, u16 num_pong_bytes UNNEEDED, u16 padlen /* Generated stub for master_badmsg */ void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg) { fprintf(stderr, "master_badmsg called!\n"); abort(); } +/* Generated stub for memleak_enter_allocations */ +struct htable *memleak_enter_allocations(const tal_t *ctx UNNEEDED, + const void *exclude1 UNNEEDED, + const void *exclude2 UNNEEDED) +{ fprintf(stderr, "memleak_enter_allocations called!\n"); abort(); } +/* Generated stub for memleak_remove_referenced */ +void memleak_remove_referenced(struct htable *memtable UNNEEDED, const void *root UNNEEDED) +{ fprintf(stderr, "memleak_remove_referenced called!\n"); abort(); } +/* Generated stub for memleak_remove_routing_tables */ +void memleak_remove_routing_tables(struct htable *memtable UNNEEDED, + const struct routing_state *rstate UNNEEDED) +{ fprintf(stderr, "memleak_remove_routing_tables called!\n"); abort(); } /* Generated stub for new_reltimer_ */ struct oneshot *new_reltimer_(struct timers *timers UNNEEDED, const tal_t *ctx UNNEEDED, @@ -203,6 +218,9 @@ struct routing_state *new_routing_state(const tal_t *ctx UNNEEDED, /* Generated stub for next_chan */ struct chan *next_chan(const struct node *node UNNEEDED, struct chan_map_iter *i UNNEEDED) { fprintf(stderr, "next_chan called!\n"); abort(); } +/* Generated stub for notleak_ */ +void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED) +{ fprintf(stderr, "notleak_ called!\n"); abort(); } /* Generated stub for read_addresses */ struct wireaddr *read_addresses(const tal_t *ctx UNNEEDED, const u8 *ser UNNEEDED) { fprintf(stderr, "read_addresses called!\n"); abort(); } @@ -308,27 +326,6 @@ bool wire_sync_write(int fd UNNEEDED, const void *msg TAKES UNNEEDED) { fprintf(stderr, "wire_sync_write called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ -#if DEVELOPER -/* Generated stub for dump_memleak */ -bool dump_memleak(struct htable *memtable UNNEEDED) -{ fprintf(stderr, "dump_memleak called!\n"); abort(); } -/* Generated stub for memleak_enter_allocations */ -struct htable *memleak_enter_allocations(const tal_t *ctx UNNEEDED, - const void *exclude1 UNNEEDED, - const void *exclude2 UNNEEDED) -{ fprintf(stderr, "memleak_enter_allocations called!\n"); abort(); } -/* Generated stub for memleak_remove_referenced */ -void memleak_remove_referenced(struct htable *memtable UNNEEDED, const void *root UNNEEDED) -{ fprintf(stderr, "memleak_remove_referenced called!\n"); abort(); } -/* Generated stub for memleak_remove_routing_tables */ -void memleak_remove_routing_tables(struct htable *memtable UNNEEDED, - const struct routing_state *rstate UNNEEDED) -{ fprintf(stderr, "memleak_remove_routing_tables called!\n"); abort(); } -/* Generated stub for notleak_ */ -void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED) -{ fprintf(stderr, "notleak_ called!\n"); abort(); } -#endif /* DEVELOPER */ - #if EXPERIMENTAL_FEATURES /* Generated stub for decode_scid_query_flags */ bigsize_t *decode_scid_query_flags(const tal_t *ctx UNNEEDED, diff --git a/onchaind/test/run-grind_feerate-bug.c b/onchaind/test/run-grind_feerate-bug.c index 0046ffcd7..ae305148e 100644 --- a/onchaind/test/run-grind_feerate-bug.c +++ b/onchaind/test/run-grind_feerate-bug.c @@ -23,6 +23,9 @@ bool derive_keyset(const struct pubkey *per_commitment_point UNNEEDED, const struct basepoints *other UNNEEDED, struct keyset *keyset UNNEEDED) { fprintf(stderr, "derive_keyset called!\n"); abort(); } +/* Generated stub for dump_memleak */ +bool dump_memleak(struct htable *memtable UNNEEDED) +{ fprintf(stderr, "dump_memleak called!\n"); abort(); } /* Generated stub for fromwire_fail */ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_fail called!\n"); abort(); } @@ -74,6 +77,21 @@ struct bitcoin_tx *htlc_success_tx(const tal_t *ctx UNNEEDED, /* Generated stub for master_badmsg */ void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg) { fprintf(stderr, "master_badmsg called!\n"); abort(); } +/* Generated stub for memleak_enter_allocations */ +struct htable *memleak_enter_allocations(const tal_t *ctx UNNEEDED, + const void *exclude1 UNNEEDED, + const void *exclude2 UNNEEDED) +{ fprintf(stderr, "memleak_enter_allocations called!\n"); abort(); } +/* Generated stub for memleak_remove_referenced */ +void memleak_remove_referenced(struct htable *memtable UNNEEDED, const void *root UNNEEDED) +{ fprintf(stderr, "memleak_remove_referenced called!\n"); abort(); } +/* Generated stub for memleak_scan_region */ +void memleak_scan_region(struct htable *memtable UNNEEDED, + const void *p UNNEEDED, size_t bytelen UNNEEDED) +{ fprintf(stderr, "memleak_scan_region called!\n"); abort(); } +/* Generated stub for notleak_ */ +void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED) +{ fprintf(stderr, "notleak_ called!\n"); abort(); } /* Generated stub for onchain_wire_type_name */ const char *onchain_wire_type_name(int e UNNEEDED) { fprintf(stderr, "onchain_wire_type_name called!\n"); abort(); } @@ -144,27 +162,6 @@ u8 *towire_onchain_unwatch_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx { fprintf(stderr, "towire_onchain_unwatch_tx called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ -#if DEVELOPER -/* Generated stub for dump_memleak */ -bool dump_memleak(struct htable *memtable UNNEEDED) -{ fprintf(stderr, "dump_memleak called!\n"); abort(); } -/* Generated stub for memleak_enter_allocations */ -struct htable *memleak_enter_allocations(const tal_t *ctx UNNEEDED, - const void *exclude1 UNNEEDED, - const void *exclude2 UNNEEDED) -{ fprintf(stderr, "memleak_enter_allocations called!\n"); abort(); } -/* Generated stub for memleak_remove_referenced */ -void memleak_remove_referenced(struct htable *memtable UNNEEDED, const void *root UNNEEDED) -{ fprintf(stderr, "memleak_remove_referenced called!\n"); abort(); } -/* Generated stub for memleak_scan_region */ -void memleak_scan_region(struct htable *memtable UNNEEDED, - const void *p UNNEEDED, size_t bytelen UNNEEDED) -{ fprintf(stderr, "memleak_scan_region called!\n"); abort(); } -/* Generated stub for notleak_ */ -void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED) -{ fprintf(stderr, "notleak_ called!\n"); abort(); } -#endif /* DEVELOPER */ - /* Stubs which do get called. */ u8 *towire_hsm_sign_local_htlc_tx(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, struct amount_sat input_amount UNNEEDED) { diff --git a/onchaind/test/run-grind_feerate.c b/onchaind/test/run-grind_feerate.c index 0f6087895..99cc0e663 100644 --- a/onchaind/test/run-grind_feerate.c +++ b/onchaind/test/run-grind_feerate.c @@ -24,6 +24,9 @@ bool derive_keyset(const struct pubkey *per_commitment_point UNNEEDED, const struct basepoints *other UNNEEDED, struct keyset *keyset UNNEEDED) { fprintf(stderr, "derive_keyset called!\n"); abort(); } +/* Generated stub for dump_memleak */ +bool dump_memleak(struct htable *memtable UNNEEDED) +{ fprintf(stderr, "dump_memleak called!\n"); abort(); } /* Generated stub for fromwire_fail */ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_fail called!\n"); abort(); } @@ -86,6 +89,21 @@ struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx UNNEEDED, /* Generated stub for master_badmsg */ void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg) { fprintf(stderr, "master_badmsg called!\n"); abort(); } +/* Generated stub for memleak_enter_allocations */ +struct htable *memleak_enter_allocations(const tal_t *ctx UNNEEDED, + const void *exclude1 UNNEEDED, + const void *exclude2 UNNEEDED) +{ fprintf(stderr, "memleak_enter_allocations called!\n"); abort(); } +/* Generated stub for memleak_remove_referenced */ +void memleak_remove_referenced(struct htable *memtable UNNEEDED, const void *root UNNEEDED) +{ fprintf(stderr, "memleak_remove_referenced called!\n"); abort(); } +/* Generated stub for memleak_scan_region */ +void memleak_scan_region(struct htable *memtable UNNEEDED, + const void *p UNNEEDED, size_t bytelen UNNEEDED) +{ fprintf(stderr, "memleak_scan_region called!\n"); abort(); } +/* Generated stub for notleak_ */ +void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED) +{ fprintf(stderr, "notleak_ called!\n"); abort(); } /* Generated stub for peer_billboard */ void peer_billboard(bool perm UNNEEDED, const char *fmt UNNEEDED, ...) { fprintf(stderr, "peer_billboard called!\n"); abort(); } @@ -166,27 +184,6 @@ bool wire_sync_write(int fd UNNEEDED, const void *msg TAKES UNNEEDED) { fprintf(stderr, "wire_sync_write called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ -#if DEVELOPER -/* Generated stub for dump_memleak */ -bool dump_memleak(struct htable *memtable UNNEEDED) -{ fprintf(stderr, "dump_memleak called!\n"); abort(); } -/* Generated stub for memleak_enter_allocations */ -struct htable *memleak_enter_allocations(const tal_t *ctx UNNEEDED, - const void *exclude1 UNNEEDED, - const void *exclude2 UNNEEDED) -{ fprintf(stderr, "memleak_enter_allocations called!\n"); abort(); } -/* Generated stub for memleak_remove_referenced */ -void memleak_remove_referenced(struct htable *memtable UNNEEDED, const void *root UNNEEDED) -{ fprintf(stderr, "memleak_remove_referenced called!\n"); abort(); } -/* Generated stub for memleak_scan_region */ -void memleak_scan_region(struct htable *memtable UNNEEDED, - const void *p UNNEEDED, size_t bytelen UNNEEDED) -{ fprintf(stderr, "memleak_scan_region called!\n"); abort(); } -/* Generated stub for notleak_ */ -void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED) -{ fprintf(stderr, "notleak_ called!\n"); abort(); } -#endif - int main(int argc, char *argv[]) { setup_locale();