mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 20:54:23 +01:00
wire/tlvstream: suppress gcc -O3 warning about prev_type.
Use a pointer, so it's explicit and gcc is happy. We avoid the allocation by pointing it to another stack var. ./wire/tlvstream.c:81:22: error: ‘prev_type’ may be used uninitialized in this function [-Werror=maybe-uninitialized] Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
02609773c0
commit
296cfe8d1b
@@ -24,8 +24,8 @@ bool fromwire_tlvs(const u8 **cursor, size_t *max,
|
||||
size_t num_types,
|
||||
void *record)
|
||||
{
|
||||
u64 prev_type;
|
||||
bool first = true;
|
||||
/* prev_type points to prev_type_store after first iter. */
|
||||
u64 prev_type_store, *prev_type = NULL;
|
||||
|
||||
/* BOLT-EXPERIMENTAL #1:
|
||||
*
|
||||
@@ -78,8 +78,8 @@ bool fromwire_tlvs(const u8 **cursor, size_t *max,
|
||||
* - if decoded `type`s are not monotonically-increasing:
|
||||
* - MUST fail to parse the `tlv_stream`.
|
||||
*/
|
||||
if (!first && type <= prev_type) {
|
||||
if (type == prev_type)
|
||||
if (prev_type && type <= *prev_type) {
|
||||
if (type == *prev_type)
|
||||
SUPERVERBOSE("duplicate tlv type");
|
||||
else
|
||||
SUPERVERBOSE("invalid ordering");
|
||||
@@ -127,8 +127,8 @@ bool fromwire_tlvs(const u8 **cursor, size_t *max,
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
prev_type = type;
|
||||
prev_type = &prev_type_store;
|
||||
*prev_type = type;
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user