From e4c6fd89b785b48bb5ccd7a367199919189b8470 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 31 Jan 2020 20:59:00 +0000 Subject: [PATCH] Add missing `extern` qualifiers for gcc 10 GCC 10 defaults to `-fno-common`. no longer automatically sharing global variable definitions, which makes it important to define them in only one place (otherwise there will be duplicate definition errors). Add `extern` qualifiers where (I think) is the best place for them. --- common/daemon.c | 2 -- common/daemon.h | 2 -- common/memleak.c | 2 ++ common/memleak.h | 2 ++ common/test/run-sphinx.c | 2 +- connectd/test/run-initiator-success.c | 2 +- connectd/test/run-responder-success.c | 2 +- plugins/libplugin.c | 2 +- wire/test/run-peer-wire.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/daemon.c b/common/daemon.c index 36c16938f..6ebd73949 100644 --- a/common/daemon.c +++ b/common/daemon.c @@ -18,8 +18,6 @@ #include #include -struct backtrace_state *backtrace_state; - #if BACKTRACE_SUPPORTED static void (*bt_print)(const char *fmt, ...) PRINTF_FMT(1,2); static void (*bt_exit)(void); diff --git a/common/daemon.h b/common/daemon.h index 3fbfb570a..b1703685d 100644 --- a/common/daemon.h +++ b/common/daemon.h @@ -20,6 +20,4 @@ void daemon_shutdown(void); /* Kick in a debugger if they set --debugger */ void daemon_maybe_debug(char *argv[]); -struct backtrace_state *backtrace_state; - #endif /* LIGHTNING_COMMON_DAEMON_H */ diff --git a/common/memleak.c b/common/memleak.c index 0b1b4b9cc..84c3bb6f7 100644 --- a/common/memleak.c +++ b/common/memleak.c @@ -7,6 +7,8 @@ #include #include +struct backtrace_state *backtrace_state; + #if DEVELOPER static bool memleak_track; diff --git a/common/memleak.h b/common/memleak.h index e93586878..8852b99e3 100644 --- a/common/memleak.h +++ b/common/memleak.h @@ -66,4 +66,6 @@ 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); +extern struct backtrace_state *backtrace_state; + #endif /* LIGHTNING_COMMON_MEMLEAK_H */ diff --git a/common/test/run-sphinx.c b/common/test/run-sphinx.c index b89ee9cf2..649908818 100644 --- a/common/test/run-sphinx.c +++ b/common/test/run-sphinx.c @@ -47,7 +47,7 @@ size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) { fprintf(stderr, "bigsize_put called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ -secp256k1_context *secp256k1_ctx; +extern secp256k1_context *secp256k1_ctx; static struct secret secret_from_hex(const char *hex) { diff --git a/connectd/test/run-initiator-success.c b/connectd/test/run-initiator-success.c index 41570064a..84876ecd5 100644 --- a/connectd/test/run-initiator-success.c +++ b/connectd/test/run-initiator-success.c @@ -104,7 +104,7 @@ static bool secret_eq_str(const struct secret *s, const char *str) return secret_eq_consttime(s, &expect); } -secp256k1_context *secp256k1_ctx; +extern secp256k1_context *secp256k1_ctx; const void *trc; static struct pubkey rs_pub, ls_pub, e_pub; static struct privkey ls_priv, e_priv; diff --git a/connectd/test/run-responder-success.c b/connectd/test/run-responder-success.c index 48e15f612..2ebf2532e 100644 --- a/connectd/test/run-responder-success.c +++ b/connectd/test/run-responder-success.c @@ -104,7 +104,7 @@ static bool secret_eq_str(const struct secret *s, const char *str) return secret_eq_consttime(s, &expect); } -secp256k1_context *secp256k1_ctx; +extern secp256k1_context *secp256k1_ctx; static struct pubkey ls_pub, e_pub; static struct privkey ls_priv, e_priv; diff --git a/plugins/libplugin.c b/plugins/libplugin.c index 9674b98b8..b7eda2429 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -35,7 +35,7 @@ static size_t in_timer; bool deprecated_apis; -const struct chainparams *chainparams; +extern const struct chainparams *chainparams; struct plugin_timer { struct timer timer; diff --git a/wire/test/run-peer-wire.c b/wire/test/run-peer-wire.c index 746a50c95..6a739b8fc 100644 --- a/wire/test/run-peer-wire.c +++ b/wire/test/run-peer-wire.c @@ -12,7 +12,7 @@ #include #include -secp256k1_context *secp256k1_ctx; +extern secp256k1_context *secp256k1_ctx; /* AUTOGENERATED MOCKS START */ /* Generated stub for amount_asset_is_main */