]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
clang tidy generates use-after-move warning 57878/head
authorSuyash Dongre <suyashd999@gmail.com>
Tue, 4 Jun 2024 18:47:48 +0000 (00:17 +0530)
committerSuyash Dongre <suyashd999@gmail.com>
Wed, 3 Jul 2024 16:42:36 +0000 (22:12 +0530)
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 <suyashd999@gmail.com>
src/cls/queue/cls_queue_src.cc

index 028b1cb123c913aea2158df0675b910b22469ef3..37de32ea018d695759c87fdd380aab70bd23ae24 100644 (file)
@@ -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