From 028dcb875b7eaeedfc1e444730ae56595f4e5b7c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 14 Aug 2023 17:09:45 +0930 Subject: [PATCH] channeld: fix gcc-12.3.0 -O3 warning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` In function ‘peer_reconnect’, inlined from ‘init_channel’ at channeld/channeld.c:5890:3, inlined from ‘main’ at channeld/channeld.c:5951:2: channeld/channeld.c:5028:21: error: ‘next_matches_inflight’ may be used uninitialized [-Werror=maybe-uninitialized] 5027 | if (remote_next_funding && !next_matches_current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5028 | && !next_matches_inflight) { | ^~~~~~~~~~~~~~~~~~~~~~~~~ channeld/channeld.c: In function ‘main’: channeld/channeld.c:4595:36: note: ‘next_matches_inflight’ was declared here 4595 | bool next_matches_current, next_matches_inflight; | ^~~~~~~~~~~~~~~~~~~~~ channeld/channeld.c:5042:57: error: ‘inflight’ may be used uninitialized [-Werror=maybe-uninitialized] 5042 | &inflight->outpoint.txid), | ^ channeld/channeld.c:4594:26: note: ‘inflight’ was declared here 4594 | struct inflight *inflight; | ^~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:300: channeld/channeld.o] Error 1 ``` Signed-off-by: Rusty Russell --- channeld/channeld.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/channeld/channeld.c b/channeld/channeld.c index b0c7369ab..5d947fcad 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -4614,7 +4614,6 @@ static void peer_reconnect(struct peer *peer, bool dataloss_protect, check_extra_fields; const u8 **premature_msgs = tal_arr(peer, const u8 *, 0); struct inflight *inflight; - bool next_matches_current, next_matches_inflight; struct bitcoin_txid *local_next_funding, *remote_next_funding; struct tlv_channel_reestablish_tlvs *send_tlvs, *recv_tlvs; @@ -4632,12 +4631,12 @@ static void peer_reconnect(struct peer *peer, get_per_commitment_point(peer->next_index[LOCAL] - 1, &my_current_per_commitment_point, NULL); + inflight = last_inflight(peer); + if (peer->experimental_upgrade) { /* Subtle: we free tmpctx below as we loop, so tal off peer */ send_tlvs = tlv_channel_reestablish_tlvs_new(peer); - inflight = last_inflight(peer); - /* If inflight with no sigs on it, send next_funding */ if (inflight && !inflight->last_tx) send_tlvs->next_funding = &inflight->outpoint.txid; @@ -5039,6 +5038,8 @@ static void peer_reconnect(struct peer *peer, remote_next_funding = (recv_tlvs ? recv_tlvs->next_funding : NULL); if (local_next_funding || remote_next_funding) { + bool next_matches_current = false, next_matches_inflight = false; + if (remote_next_funding) { next_matches_current = bitcoin_txid_eq(remote_next_funding, &peer->channel->funding.txid);