MediaMetrics: Fix clang-tidy warnings
Test: atest mediametrics_tests
Bug: 153658358
Change-Id: Ic3c05de5466df24ffd37b224c97ac1138257a73c
diff --git a/services/mediametrics/AnalyticsState.h b/services/mediametrics/AnalyticsState.h
index e8fedcf..b648947 100644
--- a/services/mediametrics/AnalyticsState.h
+++ b/services/mediametrics/AnalyticsState.h
@@ -98,7 +98,7 @@
}
if (ll > 0) {
auto [s, l] = mTransactionLog.dump(ll, sinceNs, prefix);
- ss << std::move(s);
+ ss << s;
ll -= l;
}
if (ll > 0) {
@@ -107,7 +107,7 @@
}
if (ll > 0) {
auto [s, l] = mTimeMachine.dump(ll, sinceNs, prefix);
- ss << std::move(s);
+ ss << s;
ll -= l;
}
return { ss.str(), lines - ll };
diff --git a/services/mediametrics/AudioAnalytics.cpp b/services/mediametrics/AudioAnalytics.cpp
index f80516e..3f9a42f 100644
--- a/services/mediametrics/AudioAnalytics.cpp
+++ b/services/mediametrics/AudioAnalytics.cpp
@@ -115,7 +115,7 @@
if (ll > 0) {
auto [s, l] = mAnalyticsState->dump(ll, sinceNs, prefix);
- ss << std::move(s);
+ ss << s;
ll -= l;
}
if (ll > 0) {
@@ -124,7 +124,7 @@
}
if (ll > 0) {
auto [s, l] = mPreviousAnalyticsState->dump(ll, sinceNs, prefix);
- ss << std::move(s);
+ ss << s;
ll -= l;
}
return { ss.str(), lines - ll };
diff --git a/services/mediametrics/TimeMachine.h b/services/mediametrics/TimeMachine.h
index 75819ba..29adeae 100644
--- a/services/mediametrics/TimeMachine.h
+++ b/services/mediametrics/TimeMachine.h
@@ -152,7 +152,7 @@
std::string s = dump(mKey, tsPair, time);
if (s.size() > 0) {
--ll;
- ss << std::move(s);
+ ss << s;
}
}
return { ss.str(), lines - ll };
@@ -319,7 +319,7 @@
if (it == mHistory.end()) continue;
remoteKeyHistory = it->second;
}
- std::lock_guard(getLockForKey(remoteKey));
+ std::lock_guard lock(getLockForKey(remoteKey));
remoteKeyHistory->putProp(remoteName, prop, time);
}
return NO_ERROR;
@@ -426,7 +426,7 @@
if (prefix != nullptr && !startsWith(it->first, prefix)) break;
std::lock_guard lock(getLockForKey(it->first));
auto [s, l] = it->second->dump(ll, sinceNs);
- ss << std::move(s);
+ ss << s;
ll -= l;
}
return { ss.str(), lines - ll };
@@ -441,7 +441,7 @@
// Finds a KeyHistory from a URL. Returns nullptr if not found.
std::shared_ptr<KeyHistory> getKeyHistoryFromUrl(
- std::string url, std::string* key, std::string *prop) const {
+ const std::string& url, std::string* key, std::string *prop) const {
std::lock_guard lock(mLock);
auto it = mHistory.upper_bound(url);
diff --git a/services/mediametrics/TransactionLog.h b/services/mediametrics/TransactionLog.h
index 2359eec..4f09bb0 100644
--- a/services/mediametrics/TransactionLog.h
+++ b/services/mediametrics/TransactionLog.h
@@ -142,7 +142,7 @@
--ll;
}
auto [s, l] = dumpMapTimeItem(mLog, ll, sinceNs, prefix);
- ss << std::move(s);
+ ss << s;
ll -= l;
// Grouped by item key (category)
@@ -158,7 +158,7 @@
if (prefix != nullptr && !startsWith(it->first, prefix)) break;
auto [s, l] = dumpMapTimeItem(it->second, ll - 1, sinceNs, prefix);
if (l == 0) continue; // don't show empty groups (due to sinceNs).
- ss << " " << it->first << "\n" << std::move(s);
+ ss << " " << it->first << "\n" << s;
ll -= l + 1;
}
return { ss.str(), lines - ll };
diff --git a/services/mediametrics/tests/mediametrics_tests.cpp b/services/mediametrics/tests/mediametrics_tests.cpp
index b8e566e..78eb71c 100644
--- a/services/mediametrics/tests/mediametrics_tests.cpp
+++ b/services/mediametrics/tests/mediametrics_tests.cpp
@@ -79,7 +79,7 @@
const int mFinal;
public:
- Thunk(decltype(mF) f, int final) : mF(f), mFinal(final) {}
+ explicit Thunk(decltype(mF) f, int final) : mF(std::move(f)), mFinal(final) {}
~Thunk() { mF(mFinal); }
void thunk(int value) { mF(value); }
};
@@ -139,7 +139,7 @@
std::function<void()> mF;
public:
- Thunk(decltype(mF) f) : mF(f) {}
+ explicit Thunk(decltype(mF) f) : mF(std::move(f)) {}
void thunk() { mF(); }
};