summaryrefslogtreecommitdiffstats
path: root/automotive/vehicle
diff options
context:
space:
mode:
authorLakshman Annadorai <lakshmana@google.com>2020-09-11 11:25:43 -0700
committerLakshman Annadorai <lakshmana@google.com>2020-09-22 21:54:42 +0000
commitbfaf79c9c6f0ea02656d2dab14f4d74949afe70e (patch)
tree6497fec873dfb8fbcd11cdd633a1bde052ab3633 /automotive/vehicle
parentf10a9af711515da477fff30960fa1888a564b1a7 (diff)
downloadplatform_hardware_interfaces-bfaf79c9c6f0ea02656d2dab14f4d74949afe70e.tar.gz
platform_hardware_interfaces-bfaf79c9c6f0ea02656d2dab14f4d74949afe70e.tar.bz2
platform_hardware_interfaces-bfaf79c9c6f0ea02656d2dab14f4d74949afe70e.zip
Remove MIN and MAX checking for hidl_enum in UserHalHelper native library.
VehiclePropValue enums is not sorted by their values. Thus obtaining MIN and MAX values for this enum is O(N), which is the same as looping through all the values and checking whether a given int32_t is in the enum. Test: Tested with `atest -c android.hardware.automotive.vehicle@2.0-utils-unit-tests`. Bug: 168249409 Change-Id: I296a56e31caa7a5ee69eac49806810f83e46571e (cherry picked from commit b7d50b91eb08c0d321718e3d74e740f3b04b3eac)
Diffstat (limited to 'automotive/vehicle')
-rw-r--r--automotive/vehicle/2.0/utils/UserHalHelper.cpp5
1 files changed, 0 insertions, 5 deletions
diff --git a/automotive/vehicle/2.0/utils/UserHalHelper.cpp b/automotive/vehicle/2.0/utils/UserHalHelper.cpp
index fcfe4bf17f..abf59b74e3 100644
--- a/automotive/vehicle/2.0/utils/UserHalHelper.cpp
+++ b/automotive/vehicle/2.0/utils/UserHalHelper.cpp
@@ -141,11 +141,6 @@ Result<void> parseUserAssociations(const hidl_vec<int32_t>& int32Values, size_t
template <typename T>
Result<T> verifyAndCast(int32_t value) {
T castValue = static_cast<T>(value);
- const auto iter = hidl_enum_range<T>();
- if (castValue < *iter.begin() || castValue > *std::prev(iter.end())) {
- return Error() << "Value " << value << " not in range [" << toString(*iter.begin()) << ", "
- << toString(*std::prev(iter.end())) << "]";
- }
for (const auto& v : hidl_enum_range<T>()) {
if (castValue == v) {
return castValue;