Merge "Fix performance-for-range-copy warnings"

This commit is contained in:
Treehugger Robot 2018-12-12 17:46:46 +00:00 committed by Gerrit Code Review
commit fe3becb56b
6 changed files with 16 additions and 16 deletions

View file

@ -273,7 +273,7 @@ bool Subprocess::ForkAndExec(std::string* error) {
} }
std::vector<std::string> joined_env; std::vector<std::string> joined_env;
for (auto it : env) { for (const auto& it : env) {
const char* key = it.first.c_str(); const char* key = it.first.c_str();
const char* value = it.second.c_str(); const char* value = it.second.c_str();
joined_env.push_back(android::base::StringPrintf("%s=%s", key, value)); joined_env.push_back(android::base::StringPrintf("%s=%s", key, value));

View file

@ -281,7 +281,7 @@ TEST_F(Conformance, GetVarAll) {
std::vector<std::string> vars; std::vector<std::string> vars;
EXPECT_EQ(fb->GetVarAll(&vars), SUCCESS) << "getvar:all failed"; EXPECT_EQ(fb->GetVarAll(&vars), SUCCESS) << "getvar:all failed";
EXPECT_GT(vars.size(), 0) << "getvar:all did not respond with any INFO responses"; EXPECT_GT(vars.size(), 0) << "getvar:all did not respond with any INFO responses";
for (const auto s : vars) { for (const auto& s : vars) {
EXPECT_LE(s.size(), FB_RESPONSE_SZ - 4) EXPECT_LE(s.size(), FB_RESPONSE_SZ - 4)
<< "getvar:all included an INFO response: 'INFO" + s << "' which is too long"; << "getvar:all included an INFO response: 'INFO" + s << "' which is too long";
} }
@ -316,7 +316,7 @@ TEST_F(Conformance, PartitionInfo) {
EXPECT_GT(parts.size(), 0) EXPECT_GT(parts.size(), 0)
<< "getvar:all did not report any partition-size: through INFO responses"; << "getvar:all did not report any partition-size: through INFO responses";
std::set<std::string> allowed{"ext4", "f2fs", "raw"}; std::set<std::string> allowed{"ext4", "f2fs", "raw"};
for (const auto p : parts) { for (const auto& p : parts) {
EXPECT_GE(std::get<1>(p), 0); EXPECT_GE(std::get<1>(p), 0);
std::string part(std::get<0>(p)); std::string part(std::get<0>(p));
std::set<std::string> allowed{"ext4", "f2fs", "raw"}; std::set<std::string> allowed{"ext4", "f2fs", "raw"};
@ -355,7 +355,7 @@ TEST_F(Conformance, Slots) {
if (num_slots > 0) { if (num_slots > 0) {
EXPECT_EQ(fb->GetVar("current-slot", &var), SUCCESS) << "getvar:current-slot failed"; EXPECT_EQ(fb->GetVar("current-slot", &var), SUCCESS) << "getvar:current-slot failed";
for (const auto p : parts) { for (const auto& p : parts) {
std::string part(std::get<0>(p)); std::string part(std::get<0>(p));
std::regex reg("([[:graph:]]*)_([[:lower:]])"); std::regex reg("([[:graph:]]*)_([[:lower:]])");
std::smatch sm; std::smatch sm;
@ -378,7 +378,7 @@ TEST_F(Conformance, Slots) {
} }
} }
// Ensure each partition has the correct slot suffix // Ensure each partition has the correct slot suffix
for (const auto iter : part_slots) { for (const auto& iter : part_slots) {
const std::set<char>& char_set = iter.second; const std::set<char>& char_set = iter.second;
std::string chars; std::string chars;
for (char c : char_set) { for (char c : char_set) {
@ -572,7 +572,7 @@ TEST_F(LockPermissions, DownloadFlash) {
std::vector<std::tuple<std::string, uint64_t>> parts; std::vector<std::tuple<std::string, uint64_t>> parts;
EXPECT_EQ(fb->Partitions(&parts), SUCCESS) << "getvar:all failed in locked mode"; EXPECT_EQ(fb->Partitions(&parts), SUCCESS) << "getvar:all failed in locked mode";
std::string resp; std::string resp;
for (const auto tup : parts) { for (const auto& tup : parts) {
EXPECT_EQ(fb->Flash(std::get<0>(tup), &resp), DEVICE_FAIL) EXPECT_EQ(fb->Flash(std::get<0>(tup), &resp), DEVICE_FAIL)
<< "Device did not respond with FAIL when trying to flash '" << std::get<0>(tup) << "Device did not respond with FAIL when trying to flash '" << std::get<0>(tup)
<< "' in locked mode"; << "' in locked mode";
@ -585,7 +585,7 @@ TEST_F(LockPermissions, Erase) {
std::vector<std::tuple<std::string, uint64_t>> parts; std::vector<std::tuple<std::string, uint64_t>> parts;
EXPECT_EQ(fb->Partitions(&parts), SUCCESS) << "getvar:all failed"; EXPECT_EQ(fb->Partitions(&parts), SUCCESS) << "getvar:all failed";
std::string resp; std::string resp;
for (const auto tup : parts) { for (const auto& tup : parts) {
EXPECT_EQ(fb->Erase(std::get<0>(tup), &resp), DEVICE_FAIL) EXPECT_EQ(fb->Erase(std::get<0>(tup), &resp), DEVICE_FAIL)
<< "Device did not respond with FAIL when trying to erase '" << std::get<0>(tup) << "Device did not respond with FAIL when trying to erase '" << std::get<0>(tup)
<< "' in locked mode"; << "' in locked mode";
@ -601,7 +601,7 @@ TEST_F(LockPermissions, SetActive) {
EXPECT_EQ(fb->GetVar("slot-count", &resp), SUCCESS) << "getvar:slot-count failed"; EXPECT_EQ(fb->GetVar("slot-count", &resp), SUCCESS) << "getvar:slot-count failed";
int32_t num_slots = strtol(resp.c_str(), nullptr, 10); int32_t num_slots = strtol(resp.c_str(), nullptr, 10);
for (const auto tup : parts) { for (const auto& tup : parts) {
std::string part(std::get<0>(tup)); std::string part(std::get<0>(tup));
std::regex reg("([[:graph:]]*)_([[:lower:]])"); std::regex reg("([[:graph:]]*)_([[:lower:]])");
std::smatch sm; std::smatch sm;
@ -1554,12 +1554,12 @@ INSTANTIATE_TEST_CASE_P(XMLSparseTest, SparseTestPartition,
void GenerateXmlTests(const extension::Configuration& config) { void GenerateXmlTests(const extension::Configuration& config) {
// Build the getvar tests // Build the getvar tests
for (const auto it : config.getvars) { for (const auto& it : config.getvars) {
GETVAR_XML_TESTS.push_back(std::make_pair(it.first, it.second)); GETVAR_XML_TESTS.push_back(std::make_pair(it.first, it.second));
} }
// Build the partition tests, to interface with gtest we need to do it this way // Build the partition tests, to interface with gtest we need to do it this way
for (const auto it : config.partitions) { for (const auto& it : config.partitions) {
const auto tup = std::make_tuple(it.first, it.second); const auto tup = std::make_tuple(it.first, it.second);
PARTITION_XML_TESTS.push_back(tup); // All partitions PARTITION_XML_TESTS.push_back(tup); // All partitions
@ -1581,7 +1581,7 @@ void GenerateXmlTests(const extension::Configuration& config) {
// Build the packed tests, only useful if we have a hash // Build the packed tests, only useful if we have a hash
if (!config.checksum.empty()) { if (!config.checksum.empty()) {
for (const auto it : config.packed) { for (const auto& it : config.packed) {
for (const auto& test : it.second.tests) { for (const auto& test : it.second.tests) {
const auto tup = std::make_tuple(it.first, test); const auto tup = std::make_tuple(it.first, test);
if (test.expect == extension::OKAY) { // only testing the success case if (test.expect == extension::OKAY) { // only testing the success case
@ -1608,7 +1608,7 @@ void GenerateXmlTests(const extension::Configuration& config) {
} }
// Build oem tests // Build oem tests
for (const auto it : config.oem) { for (const auto& it : config.oem) {
auto oem_cmd = it.second; auto oem_cmd = it.second;
for (const auto& t : oem_cmd.tests) { for (const auto& t : oem_cmd.tests) {
OEM_XML_TESTS.push_back(std::make_tuple(it.first, oem_cmd.restricted, t)); OEM_XML_TESTS.push_back(std::make_tuple(it.first, oem_cmd.restricted, t));

View file

@ -499,7 +499,7 @@ bool fs_mgr_overlayfs_mount(const std::string& mount_point) {
// hijack __mount() report format to help triage // hijack __mount() report format to help triage
auto report = "__mount(source=overlay,target="s + mount_point + ",type=overlay"; auto report = "__mount(source=overlay,target="s + mount_point + ",type=overlay";
const auto opt_list = android::base::Split(options, ","); const auto opt_list = android::base::Split(options, ",");
for (const auto opt : opt_list) { for (const auto& opt : opt_list) {
if (android::base::StartsWith(opt, kUpperdirOption)) { if (android::base::StartsWith(opt, kUpperdirOption)) {
report = report + "," + opt; report = report + "," + opt;
break; break;

View file

@ -260,7 +260,7 @@ bool DwarfCfa<AddressType>::LogInstruction(uint32_t indent, uint64_t cfa_offset,
} }
// Log any of the expression data. // Log any of the expression data.
for (const auto line : expression_lines) { for (const auto& line : expression_lines) {
log(indent + 1, "%s", line.c_str()); log(indent + 1, "%s", line.c_str());
} }
return true; return true;

View file

@ -224,7 +224,7 @@ int SaveData(pid_t pid) {
sp_map_start = map_info->start; sp_map_start = map_info->start;
} }
for (auto frame : unwinder.frames()) { for (const auto& frame : unwinder.frames()) {
map_info = maps.Find(frame.sp); map_info = maps.Find(frame.sp);
if (map_info != nullptr && sp_map_start != map_info->start) { if (map_info != nullptr && sp_map_start != map_info->start) {
stacks.emplace_back(std::make_pair(frame.sp, map_info->end)); stacks.emplace_back(std::make_pair(frame.sp, map_info->end));

View file

@ -610,7 +610,7 @@ std::string llkFormat(bool flag) {
std::string llkFormat(const std::unordered_set<std::string>& blacklist) { std::string llkFormat(const std::unordered_set<std::string>& blacklist) {
std::string ret; std::string ret;
for (auto entry : blacklist) { for (const auto& entry : blacklist) {
if (ret.size()) { if (ret.size()) {
ret += ","; ret += ",";
} }