Fix build with clang-r563880
system/keymaster/include/keymaster/contexts/soft_keymaster_context.h:70:28: error: virtual function 'GetSupportedAlgorithms' has a different return type ('keymaster_algorithm_t *') than the function it overrides
(which has return type 'const keymaster_algorithm_t *')
70 | keymaster_algorithm_t* GetSupportedAlgorithms(size_t* algorithms_count) const override;
| ~~~~~~~~~~~~~~~~~~~~~~ ^
system/keymaster/include/keymaster/keymaster_context.h:108:42: note: overridden virtual function is here
108 | virtual const keymaster_algorithm_t* GetSupportedAlgorithms(size_t* algorithms_count) const = 0;
| ~~~~~~~~~~~~~~~~~~~~~~ ^
Test: presubmit
Bug: 401330760
Change-Id: I234a84b9acceb34c05834e0cb7427d98d9ef64a3
diff --git a/contexts/soft_keymaster_context.cpp b/contexts/soft_keymaster_context.cpp
index 0dc6030..246cee9 100644
--- a/contexts/soft_keymaster_context.cpp
+++ b/contexts/soft_keymaster_context.cpp
@@ -114,7 +114,7 @@
static keymaster_algorithm_t supported_algorithms[] = {KM_ALGORITHM_RSA, KM_ALGORITHM_EC,
KM_ALGORITHM_AES, KM_ALGORITHM_HMAC};
-keymaster_algorithm_t*
+const keymaster_algorithm_t*
SoftKeymasterContext::GetSupportedAlgorithms(size_t* algorithms_count) const {
*algorithms_count = array_length(supported_algorithms);
return supported_algorithms;
diff --git a/include/keymaster/contexts/soft_keymaster_context.h b/include/keymaster/contexts/soft_keymaster_context.h
index aae0542..73c39c2 100644
--- a/include/keymaster/contexts/soft_keymaster_context.h
+++ b/include/keymaster/contexts/soft_keymaster_context.h
@@ -67,7 +67,7 @@
KeyFactory* GetKeyFactory(keymaster_algorithm_t algorithm) const override;
OperationFactory* GetOperationFactory(keymaster_algorithm_t algorithm,
keymaster_purpose_t purpose) const override;
- keymaster_algorithm_t* GetSupportedAlgorithms(size_t* algorithms_count) const override;
+ const keymaster_algorithm_t* GetSupportedAlgorithms(size_t* algorithms_count) const override;
keymaster_error_t UpgradeKeyBlob(const KeymasterKeyBlob& key_to_upgrade,
const AuthorizationSet& upgrade_params,
KeymasterKeyBlob* upgraded_key) const override;