channeld: fix gcc-12.3.0 -O3 warning.

```
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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-08-14 17:09:45 +09:30
parent 88448a7892
commit 028dcb875b

View file

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