From b06a68b4b80d5b3824938019a356a6a4fa15ca64 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 18 Aug 2025 10:41:07 +0800 Subject: [PATCH] os/Transaction: initialize unused fields in TransactionData MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Initialize unused1, unused2, and unused3 fields to zero in TransactionData to ensure consistent encoding/decoding behavior. Background: In commit a0c9fec7, 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 --- src/os/Transaction.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/os/Transaction.h b/src/os/Transaction.h index 91c7811f115..dc0c03949e3 100644 --- a/src/os/Transaction.h +++ b/src/os/Transaction.h @@ -195,6 +195,7 @@ public: TransactionData(TransactionData&& other) noexcept : ops(other.ops), fadvise_flags(other.fadvise_flags) { + unused1 = unused2 = unused3 = 0; other.ops = 0; other.fadvise_flags = 0; } -- 2.39.5