Replace cast operator with getValue() for key store return codes
The value of the error code is not intended to be used
in checks, and instead isOk() should be used. A few places
were found which used the error codes directly via the
cast operator. To make it less likely this will happen
in the future unintentionally, the cast operator is being
removed. Some code still wants to access the error code
directly, such as when logging, so getValue() is added
for these cases.
Bug: 119771891
Test: Built for walleye successfully, basic operations with
keystore_cli_v2 tool work correctly.
Change-Id: I46e82d66dc4932472d8a5b2749ece08e398e7c88
diff --git a/keystore/keymaster_worker.cpp b/keystore/keymaster_worker.cpp
index 6dc055f..a5bcd07 100644
--- a/keystore/keymaster_worker.cpp
+++ b/keystore/keymaster_worker.cpp
@@ -108,7 +108,7 @@
error = keyStore_->del(lockedEntry);
if (!error.isOk()) {
- ALOGI("upgradeKeyBlob keystore->del failed %d", (int)error);
+ ALOGI("upgradeKeyBlob keystore->del failed %d", error.getErrorCode());
return;
}
@@ -121,7 +121,7 @@
error = keyStore_->put(lockedEntry, newBlob, charBlob);
if (!error.isOk()) {
- ALOGI("upgradeKeyBlob keystore->put failed %d", (int)error);
+ ALOGI("upgradeKeyBlob keystore->put failed %d", error.getErrorCode());
return;
}
blob = std::move(newBlob);
@@ -316,7 +316,7 @@
// one operation has been removed.
auto rc = abort(oldest);
if (operationMap_.getOperationCount() >= op_count_before_abort) {
- ALOGE("Failed to abort pruneable operation %p, error: %d", oldest.get(), int32_t(rc));
+ ALOGE("Failed to abort pruneable operation %p, error: %d", oldest.get(), rc.getErrorCode());
return false;
}
return true;