From 3cf0f71420f65f837b93441cd5c68d5754c09750 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 13 Feb 2025 10:02:53 +0800 Subject: [PATCH] query-result-writer: reorder initialization to prevent use-after-move Reorder member variable initialization sequence to ensure `pw` is accessed before being moved. While the current use-after-move warning from clang-tidy is a false positive, this change: - Makes the initialization order more logical - Eliminates misleading static analysis warnings - Prevents potential future issues if class structure changes Signed-off-by: Kefu Chai Closes scylladb/scylladb#22830 --- mutation/mutation_partition.cc | 2 +- query-result-writer.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mutation/mutation_partition.cc b/mutation/mutation_partition.cc index 223c8aee10..bd586c085b 100644 --- a/mutation/mutation_partition.cc +++ b/mutation/mutation_partition.cc @@ -1876,8 +1876,8 @@ mutation_querier::mutation_querier(const schema& s, query::result::partition_wri query::result_memory_accounter& memory_accounter) : _schema(s) , _memory_accounter(memory_accounter) - , _pw(std::move(pw)) , _static_cells_wr(pw.start().start_static_row().start_cells()) + , _pw(std::move(pw)) { } diff --git a/query-result-writer.hh b/query-result-writer.hh index 2a228a387a..eb56a135ca 100644 --- a/query-result-writer.hh +++ b/query-result-writer.hh @@ -202,8 +202,8 @@ class range_tombstone_change; class mutation_querier { const schema& _schema; query::result_memory_accounter& _memory_accounter; - query::result::partition_writer _pw; ser::qr_partition__static_row__cells _static_cells_wr; + query::result::partition_writer _pw; bool _live_data_in_static_row{}; uint64_t _live_clustering_rows = 0; std::optional> _rows_wr;