From fb08b015f2db1369af3fceb43e18503685ce7e22 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Sat, 7 Mar 2020 17:22:40 -0800 Subject: Address the warnings in recovery code The following warnngs generate when compile with WITH_TIDY=1 .../bootable/recovery/applypatch/imgdiff.cpp:968:7: warning: 'src_ranges' used after it was moved [bugprone-use-after-move] src_ranges.Clear(); ^ .../bootable/recovery/applypatch/imgdiff.cpp:966:27: note: move occurred here split_src_ranges->push_back(std::move(src_ranges)); The logic itself seems correct since the class is meant to be cleared after move. I feel the std::move in 966 is actually useful to call the move constructor in RangeSet. So I just modify L968 to suppress the warning. Less important ones: bootable/recovery/applypatch/applypatch_modes.cpp:79:34: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg] bootable/recovery/applypatch/imgdiff.cpp:1038:30: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg] bootable/recovery/applypatch/imgdiff.cpp:1054:48: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg] bootable/recovery/updater/include/private/commands.h:310:16: warning: std::move of the variable 'patch' of the trivially-copyable type 'PatchInfo' has no effect; remove std::move() [performance-move-const-arg] bootable/recovery/updater/install.cpp:663:43: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg] Bug: 150955971 Test: build Change-Id: Ieb75f0229c47d470d4f5ac93fab39c5698d3f914 --- applypatch/imgdiff.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'applypatch/imgdiff.cpp') diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp index 6ad4a6105..91007ac3b 100644 --- a/applypatch/imgdiff.cpp +++ b/applypatch/imgdiff.cpp @@ -965,7 +965,7 @@ bool ZipModeImage::SplitZipModeImageWithLimit(const ZipModeImage& tgt_image, used_src_ranges.Insert(src_ranges); split_src_ranges->push_back(std::move(src_ranges)); } - src_ranges.Clear(); + src_ranges = {}; // We don't have enough space for the current chunk; start a new split image and handle // this chunk there. @@ -1035,7 +1035,7 @@ bool ZipModeImage::AddSplitImageFromChunkList(const ZipModeImage& tgt_image, } ZipModeImage split_tgt_image(false); - split_tgt_image.Initialize(std::move(aligned_tgt_chunks), {}); + split_tgt_image.Initialize(aligned_tgt_chunks, {}); split_tgt_image.MergeAdjacentNormalChunks(); // Construct the dummy source file based on the src_ranges. @@ -1051,7 +1051,7 @@ bool ZipModeImage::AddSplitImageFromChunkList(const ZipModeImage& tgt_image, CHECK(!src_content.empty()); ZipModeImage split_src_image(true); - split_src_image.Initialize(split_src_chunks, std::move(src_content)); + split_src_image.Initialize(split_src_chunks, src_content); split_tgt_images->push_back(std::move(split_tgt_image)); split_src_images->push_back(std::move(split_src_image)); -- cgit v1.2.3