Browse Source

developer: IFDEV() macro.

There are some more #if DEVELOPER one-liners coming, this makes them
clear, but still lets them stand out.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 5 years ago
parent
commit
a3273d4c84
  1. 11
      common/utils.h
  2. 7
      lightningd/connect_control.c
  3. 7
      lightningd/gossip_control.c
  4. 13
      lightningd/hsm_control.c
  5. 6
      lightningd/subd.c

11
common/utils.h

@ -59,4 +59,15 @@ STRUCTEQ_DEF(ripemd160, 0, u);
* complained on, so we can re-test as gcc evolves. */
#define COMPILER_WANTS_INIT(compiler_versions) = 0
/* For case where we want one thing if DEVELOPER, another if not, particularly
* for function parameters.
*
* Usefully, you can refer to DEVELOPER-only fields here. */
#if DEVELOPER
/* Make sure that nondev is evaluated, and valid */
#define IFDEV(dev, nondev) ((void)(nondev), (dev))
#else
#define IFDEV(dev, nondev) (nondev)
#endif
#endif /* LIGHTNING_COMMON_UTILS_H */

7
lightningd/connect_control.c

@ -339,11 +339,6 @@ int connectd_init(struct lightningd *ld)
int hsmfd;
struct wireaddr_internal *wireaddrs = ld->proposed_wireaddr;
enum addr_listen_announce *listen_announce = ld->proposed_listen_announce;
bool allow_localhost = false;
#if DEVELOPER
if (ld->dev_allow_localhost)
allow_localhost = true;
#endif
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0)
fatal("Could not socketpair for connectd<->gossipd");
@ -370,7 +365,7 @@ int connectd_init(struct lightningd *ld)
wireaddrs,
listen_announce,
ld->proxyaddr, ld->use_proxy_always || ld->pure_tor_setup,
allow_localhost, ld->config.use_dns,
IFDEV(ld->dev_allow_localhost, false), ld->config.use_dns,
ld->tor_service_password ? ld->tor_service_password : "");
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,

7
lightningd/gossip_control.c

@ -197,12 +197,7 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
ld->rgb,
ld->alias, ld->config.channel_update_interval,
ld->announcable,
#if DEVELOPER
ld->dev_gossip_time ? &ld->dev_gossip_time: NULL
#else
NULL
#endif
);
IFDEV(ld->dev_gossip_time ? &ld->dev_gossip_time: NULL, NULL));
subd_send_msg(ld->gossip, msg);
}

13
lightningd/hsm_control.c

@ -98,15 +98,10 @@ void hsm_init(struct lightningd *ld)
if (!wire_sync_write(ld->hsm_fd, towire_hsm_init(tmpctx,
&ld->topology->bitcoind->chainparams->bip32_key_version,
&chainhash,
#if DEVELOPER
ld->dev_force_privkey,
ld->dev_force_bip32_seed,
ld->dev_force_channel_secrets,
ld->dev_force_channel_secrets_shaseed
#else
NULL, NULL, NULL, NULL
#endif
)))
IFDEV(ld->dev_force_privkey, NULL),
IFDEV(ld->dev_force_bip32_seed, NULL),
IFDEV(ld->dev_force_channel_secrets, NULL),
IFDEV(ld->dev_force_channel_secrets_shaseed, NULL))))
err(1, "Writing init msg to hsm");
ld->wallet->bip32_base = tal(ld->wallet, struct ext_key);

6
lightningd/subd.c

@ -508,11 +508,9 @@ out:
static void destroy_subd(struct subd *sd)
{
int status;
bool fail_if_subd_fails = false;
bool fail_if_subd_fails;
#if DEVELOPER
fail_if_subd_fails = sd->ld->dev_subdaemon_fail;
#endif
fail_if_subd_fails = IFDEV(sd->ld->dev_subdaemon_fail, false);
switch (waitpid(sd->pid, &status, WNOHANG)) {
case 0:

Loading…
Cancel
Save