From fb7085441b384c2bee253fc78d21db711aa8e31a Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Fri, 30 Jun 2023 15:16:30 -0500 Subject: [PATCH] Handle key not exists errors for voltage sensor Check the key exists or not before access sensor map. Change-Id: I0ac5d63ae981ec2f984b1d464e93508560a4d030 [ROCm/amdsmi commit: 7b107258ffc27fa50684053671f86cd22852f204] --- projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc b/projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc index 4adffdd50f..856281053b 100755 --- a/projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc +++ b/projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc @@ -465,6 +465,8 @@ Monitor::getVoltSensorIndex(rsmi_voltage_type_t type) { rsmi_voltage_type_t Monitor::getVoltSensorEnum(uint64_t ind) { + // check if ind is a key or not + if (index_volt_type_map_.count(ind) == 0) return RSMI_VOLT_TYPE_INVALID; return index_volt_type_map_.at(ind); }