compiler: fix for -O3 errors.

CI revealed one:

```
cc plugins/libplugin-pay.c
plugins/libplugin-pay.c: In function ‘payment_getroute’:
plugins/libplugin-pay.c:888:17: error: ‘errstr’ may be used uninitialized [-Werror=maybe-uninitialized]
  888 |                 payment_fail(p, "%s", errstr);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plugins/libplugin-pay.c:851:21: note: ‘errstr’ was declared here
  851 |         const char *errstr;
      |                     ^~~~~~
cc1: all warnings being treated as errors
```

My local compiler gave another:

```
channeld/channeld.c: In function ‘resume_splice_negotiation’:
channeld/channeld.c:3734:23: error: ‘final_tx’ may be used uninitialized [-Werror=maybe-uninitialized]
 3734 |                 msg = towire_channeld_splice_confirmed_signed(tmpctx, final_tx,
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3735 |                                                               chan_output_index);
      |                                                               ~~~~~~~~~~~~~~~~~~
channeld/channeld.c:3461:28: note: ‘final_tx’ was declared here
 3461 |         struct bitcoin_tx *final_tx;
      |                            ^~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:298: channeld/channeld.o] Error 1
```

So fix both.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-12-07 06:43:45 +10:30
parent a48e2258c7
commit a12e41a930
2 changed files with 2 additions and 1 deletions

View file

@ -3458,7 +3458,7 @@ static void resume_splice_negotiation(struct peer *peer,
u32 chan_output_index;
struct bitcoin_signature their_sig;
struct pubkey *their_pubkey;
struct bitcoin_tx *final_tx;
struct bitcoin_tx *final_tx COMPILER_WANTS_INIT("12.3.0 -O3");
struct bitcoin_txid final_txid;
u8 **wit_stack;
struct tlv_txsigs_tlvs *txsig_tlvs, *their_txsigs_tlvs;

View file

@ -817,6 +817,7 @@ static struct route_hop *route(const tal_t *ctx,
}
}
*errmsg = NULL;
return r;
}