Skip to content

Commit b06a68b

Browse files
committed
os/Transaction: initialize unused fields in TransactionData
Initialize unused1, unused2, and unused3 fields to zero in TransactionData to ensure consistent encoding/decoding behavior. Background: In commit a0c9fec, we updated TransactionData encoding/decoding and bumped the Transaction encoding version from 9 to 10. As part of this change, we renamed three fields to mark them as unused: - largest_data_len → unused1 - largest_data_off → unused2 - largest_data_off_in_data_bl → unused3 The move constructor was also updated to stop setting these fields, leaving them uninitialized after move operations. Problem: This worked with existing tests because check-generated.sh reused struct instances, preserving stale values across encode/decode cycles. However, an upcoming test change will stop reusing instances and compare hexdumps of encoded/re-encoded values to verify consistency. Uninitialized fields cause these comparisons to fail due to garbage values. Solution: Initialize the unused fields to zero in the move constructor. This preserves existing behavior while ensuring consistent encoding. These fields can be removed entirely in a future change. Signed-off-by: Kefu Chai <[email protected]>
1 parent ee99b1a commit b06a68b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/os/Transaction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class Transaction {
195195
TransactionData(TransactionData&& other) noexcept :
196196
ops(other.ops),
197197
fadvise_flags(other.fadvise_flags) {
198+
unused1 = unused2 = unused3 = 0;
198199
other.ops = 0;
199200
other.fadvise_flags = 0;
200201
}

0 commit comments

Comments
 (0)