Skip to content

Commit

Permalink
fix: address coverity issues in (#127) (#129)
Browse files Browse the repository at this point in the history
Related to commit cf41a5a

Signed-off-by: Bagria, Narendra <[email protected]>
  • Loading branch information
narenbagria authored Dec 19, 2024
1 parent 87f846d commit 19bf641
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 28 deletions.
23 changes: 12 additions & 11 deletions conformance_tests/tools/metrics/src/test_metric_programmable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class zetMetricMetricProgrammableTest : public ::testing::Test {
}

void destroy_metric_group_handles_list(
std::vector<zet_metric_group_handle_t> metric_group_handles_list) {
std::vector<zet_metric_group_handle_t> &metric_group_handles_list) {
LOG_DEBUG << "ENTER destroy_metric_group_handles_list of size "
<< metric_group_handles_list.size();
for (auto metric_group_handle : metric_group_handles_list) {
Expand All @@ -175,6 +175,7 @@ class zetMetricMetricProgrammableTest : public ::testing::Test {
EXPECT_EQ(result, ZE_RESULT_SUCCESS)
<< "metric group destroy on handle has failed";
}
metric_group_handles_list.resize(0);
LOG_DEBUG << "LEAVE destroy_metric_group_handles_list";
}
};
Expand All @@ -188,7 +189,7 @@ TEST_F(
<< "There are no devices found that support metric programmable";
}

for (auto device_with_metric_programmable_groups :
for (auto &device_with_metric_programmable_groups :
metric_programmable_lists_with_devices) {

LOG_INFO << "description of the device being tested: "
Expand All @@ -210,7 +211,7 @@ TEST_F(zetMetricMetricProgrammableTest,
<< "There are no devices found that support metric programmable";
}

for (auto device_with_metric_programmable_groups :
for (auto &device_with_metric_programmable_groups :
metric_programmable_lists_with_devices) {

LOG_INFO << "description of the device being tested: "
Expand Down Expand Up @@ -327,7 +328,7 @@ TEST_F(
<< "There are no devices found that support metric programmable";
}

for (auto device_with_metric_programmable_groups :
for (auto &device_with_metric_programmable_groups :
metric_programmable_lists_with_devices) {

LOG_INFO << "description of the device being tested: "
Expand All @@ -351,7 +352,7 @@ TEST_F(
metric_programmable_handle, param_infos,
metric_programmable_param_info_limit);
ASSERT_GT(param_infos.size(), 0u);
for (auto param_info : param_infos) {
for (auto &param_info : param_infos) {
bool success;
std::string type_string;
std::string value_info_type_string;
Expand Down Expand Up @@ -381,7 +382,7 @@ TEST_F(
<< "There are no devices found that support metric programmable";
}

for (auto device_with_metric_programmable_groups :
for (auto &device_with_metric_programmable_groups :
metric_programmable_lists_with_devices) {

LOG_INFO << "description of the device being tested: "
Expand All @@ -407,7 +408,7 @@ TEST_F(

uint32_t param_info_ordinal = 0;
ASSERT_GT(param_infos.size(), 0u);
for (auto param_info : param_infos) {
for (auto &param_info : param_infos) {
bool success;
std::string type_string;
std::string value_info_type_string;
Expand Down Expand Up @@ -446,7 +447,7 @@ TEST_F(
<< "There are no devices found that support metric programmable";
}

for (auto device_with_metric_programmable_groups :
for (auto &device_with_metric_programmable_groups :
metric_programmable_lists_with_devices) {

LOG_INFO << "description of the device being tested: "
Expand Down Expand Up @@ -479,7 +480,7 @@ TEST_F(

uint32_t param_info_index = 0;
ASSERT_GT(param_infos.size(), 0u);
for (auto param_info : param_infos) {
for (auto &param_info : param_infos) {
parameter_values[param_info_index].value = param_info.defaultValue;
param_info_index++;
}
Expand All @@ -505,7 +506,7 @@ TEST_F(
<< "There are no devices found that support metric programmable";
}

for (auto device_with_metric_programmable_groups :
for (auto &device_with_metric_programmable_groups :
metric_programmable_lists_with_devices) {

LOG_INFO << "description of the device being tested: "
Expand Down Expand Up @@ -538,7 +539,7 @@ TEST_F(

uint32_t param_info_index = 0;
ASSERT_GT(param_infos.size(), 0u);
for (auto param_info : param_infos) {
for (auto &param_info : param_infos) {
parameter_values[param_info_index].value = param_info.defaultValue;
param_info_index++;
}
Expand Down
21 changes: 14 additions & 7 deletions conformance_tests/tools/metrics/src/test_metric_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ TEST_F(
GTEST_SKIP()
<< "No devices that have metric groups of type Tracer were found";
}
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
for (auto &device_with_metric_group_handles :
tracer_supporting_devices_list) {
device = device_with_metric_group_handles.device;
ze_result_t result;

Expand Down Expand Up @@ -125,7 +126,8 @@ TEST_F(
GTEST_SKIP()
<< "No devices that have metric groups of type Tracer were found";
}
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
for (auto &device_with_metric_group_handles :
tracer_supporting_devices_list) {
device = device_with_metric_group_handles.device;
ze_result_t result;

Expand Down Expand Up @@ -193,7 +195,8 @@ TEST_F(
GTEST_SKIP()
<< "No devices that have metric groups of type Tracer were found";
}
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
for (auto &device_with_metric_group_handles :
tracer_supporting_devices_list) {
device = device_with_metric_group_handles.device;

lzt::display_device_properties(device);
Expand Down Expand Up @@ -362,7 +365,8 @@ TEST_P(
GTEST_SKIP()
<< "No devices that have metric groups of type Tracer were found";
}
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
for (auto &device_with_metric_group_handles :
tracer_supporting_devices_list) {
device = device_with_metric_group_handles.device;

lzt::display_device_properties(device);
Expand Down Expand Up @@ -552,7 +556,8 @@ TEST_F(zetMetricTracerTest,
GTEST_SKIP()
<< "No devices that have metric groups of type Tracer were found";
}
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
for (auto &device_with_metric_group_handles :
tracer_supporting_devices_list) {
device = device_with_metric_group_handles.device;

lzt::display_device_properties(device);
Expand Down Expand Up @@ -601,7 +606,8 @@ TEST_F(zetMetricTracerTest,
GTEST_SKIP()
<< "No devices that have metric groups of type Tracer were found";
}
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
for (auto &device_with_metric_group_handles :
tracer_supporting_devices_list) {
device = device_with_metric_group_handles.device;

lzt::display_device_properties(device);
Expand Down Expand Up @@ -698,7 +704,8 @@ TEST_F(
GTEST_SKIP()
<< "No devices that have metric groups of type Tracer were found";
}
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
for (auto &device_with_metric_group_handles :
tracer_supporting_devices_list) {
device = device_with_metric_group_handles.device;
ze_result_t result;

Expand Down
24 changes: 14 additions & 10 deletions utils/test_harness/tools/src/test_harness_metric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ void verify_typed_metric_value(zet_typed_value_t result,
break;
default:
ADD_FAILURE() << "Unexpected value type returned for metric query";
break;
}
}

Expand Down Expand Up @@ -1062,7 +1063,7 @@ void generate_activatable_metric_group_list_for_device(
std::vector<zet_metric_group_handle_t> &activatable_metric_group_list) {
std::map<uint32_t, zet_metric_group_handle_t> domain_map;

for (auto group_info : metric_group_info_list) {
for (auto &group_info : metric_group_info_list) {

auto it = domain_map.find(group_info.domain);
if (it == domain_map.end()) {
Expand All @@ -1073,7 +1074,7 @@ void generate_activatable_metric_group_list_for_device(
}
}

for (auto map_entry : domain_map) {
for (auto &map_entry : domain_map) {
activatable_metric_group_list.push_back(map_entry.second);
}
}
Expand Down Expand Up @@ -1138,7 +1139,7 @@ void generate_device_list_with_activatable_metric_group_handles(
activatable_metric_group_handle_list_for_device_t list_entry;
list_entry.device = device;
list_entry.activatable_metric_group_handle_list =
activatable_metric_group_handle_list;
std::move(activatable_metric_group_handle_list);
activatable_metric_group_handles_with_devices_list.push_back(list_entry);
}
LOG_DEBUG << "LEAVE generate_activatable_devices_list";
Expand Down Expand Up @@ -1192,7 +1193,7 @@ void generate_device_list_with_metric_programmable_handles(

metric_programmable_handle_list_for_device list;
list.device = device;
list.device_description = device_description;
list.device_description = std::move(device_description);
list.metric_programmable_handle_count = metric_programmable_handle_count;
list.metric_programmable_handles_for_device = {
metric_programmable_handles.begin(),
Expand Down Expand Up @@ -1240,6 +1241,7 @@ bool programmable_param_info_type_to_string(

default:
param_info_type_is_valid = false;
break;
}
return param_info_type_is_valid;
}
Expand Down Expand Up @@ -1312,6 +1314,7 @@ bool programmable_param_info_value_info_type_to_string(
"contains an fp64 that is not a number";
value_info_type_string = "ZET_VALUE_INFO_TYPE_EXP_FLOAT64_RANGE";
oss << param_info.defaultValue.fp64;
break;

default:
EXPECT_TRUE(false)
Expand Down Expand Up @@ -1417,7 +1420,7 @@ void generate_param_info_exp_list_from_metric_programmable(

param_infos.resize(metric_programmable_properties.parameterCount);

for (auto parameter_info : param_infos) {
for (auto &parameter_info : param_infos) {
parameter_info.stype =
ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_INFO_EXP;
parameter_info.pNext = nullptr;
Expand Down Expand Up @@ -1518,13 +1521,14 @@ void generate_param_value_info_list_from_param_info(
info->stype = ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_VALUE_INFO_EXP;
info->pNext = nullptr;

zet_metric_programmable_param_value_info_exp_t *desc =
&value_info_desc[index];
desc->stype = static_cast<zet_structure_type_t>(
ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_VALUE_INFO_EXP);
desc->pNext = nullptr;

if (include_value_info_desc) {
zet_metric_programmable_param_value_info_exp_t *desc =
&value_info_desc[index];
info->pNext = desc;
desc->pNext = nullptr;
desc->stype = static_cast<zet_structure_type_t>(
ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_VALUE_INFO_EXP);
}
}

Expand Down

0 comments on commit 19bf641

Please sign in to comment.