Fix clang-tidy performance warnings in system/security.
* Use const reference type for parameters, local variables,
and for-loop index variables to avoid unnecessary copy.
Bug: 30407689
Bug: 30413223
Bug: 30413862
Change-Id: I3b9383f34e466ca6b5290bad802d535443fd0187
Test: build with WITH_TIDY=1
diff --git a/keystore/key_store_service.cpp b/keystore/key_store_service.cpp
index 759ef06..e3df13a 100644
--- a/keystore/key_store_service.cpp
+++ b/keystore/key_store_service.cpp
@@ -41,7 +41,7 @@
void KeyStoreService::binderDied(const wp<IBinder>& who) {
auto operations = mOperationMap.getOperationsForToken(who.unsafe_get());
- for (auto token : operations) {
+ for (const auto& token : operations) {
abort(token);
}
}
@@ -297,7 +297,7 @@
ALOGI("invalid number of arguments: %zu", args->size());
return ::SYSTEM_ERROR;
} else if (args->size() == 1) {
- sp<KeystoreArg> expArg = args->itemAt(0);
+ const sp<KeystoreArg>& expArg = args->itemAt(0);
if (expArg != NULL) {
Unique_BIGNUM pubExpBn(BN_bin2bn(
reinterpret_cast<const unsigned char*>(expArg->data()), expArg->size(), NULL));
@@ -1351,7 +1351,7 @@
* KM_ERROR_INVALID_OPERATION_HANDLE if token is not a valid
* operation token.
*/
-int32_t KeyStoreService::addOperationAuthTokenIfNeeded(sp<IBinder> token,
+int32_t KeyStoreService::addOperationAuthTokenIfNeeded(const sp<IBinder>& token,
std::vector<keymaster_key_param_t>* params) {
const hw_auth_token_t* authToken = NULL;
mOperationMap.getOperationAuthToken(token, &authToken);