From: Suyash Dongre Date: Tue, 4 Jun 2024 18:47:48 +0000 (+0530) Subject: clang tidy generates use-after-move warning X-Git-Tag: v20.0.0~1139^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=02e9a4c77a27ce818d4ee15d5a2ee073c019a0f2;p=ceph.git clang tidy generates use-after-move warning clang-tidy original warning: /home/suyash/ceph/src/cls/queue/cls_queue_src.cc:330:50: warning: 'bl' used after it was moved [bugprone-use-after-move] uint64_t entry_start_offset = start_offset - bl.length(); ^ /home/suyash/ceph/src/cls/queue/cls_queue_src.cc:333:14: note: move occurred here bl_chunk = std::move(bl); ^ /home/suyash/ceph/src/cls/queue/cls_queue_src.cc:330:50: note: the use happens in a later loop iteration than the move uint64_t entry_start_offset = start_offset - bl.length(); ^ Fixes: https://tracker.ceph.com/issues/66356 Signed-off-by: Suyash Dongre --- diff --git a/src/cls/queue/cls_queue_src.cc b/src/cls/queue/cls_queue_src.cc index 028b1cb123c91..37de32ea018d6 100644 --- a/src/cls/queue/cls_queue_src.cc +++ b/src/cls/queue/cls_queue_src.cc @@ -327,11 +327,11 @@ int queue_list_entries(cls_method_context_t hctx, const cls_queue_list_op& op, c } //If there is leftover data from previous iteration, append new data to leftover data - uint64_t entry_start_offset = start_offset - bl.length(); + uint64_t entry_start_offset = start_offset - bl.length(); //NOLINT(bugprone-use-after-move) CLS_LOG(20, "INFO: queue_list_entries(): Entry start offset accounting for leftover data is %lu", entry_start_offset); bl.claim_append(bl_chunk); bl_chunk = std::move(bl); - + bl.clear(); //NOLINT(bugprone-use-after-move) CLS_LOG(20, "INFO: queue_list_entries(): size of chunk %u", bl_chunk.length()); //Process the chunk of data read