Skip to content

Commit 19bf641

Browse files
authored
fix: address coverity issues in (#127) (#129)
Related to commit cf41a5a Signed-off-by: Bagria, Narendra <[email protected]>
1 parent 87f846d commit 19bf641

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

conformance_tests/tools/metrics/src/test_metric_programmable.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class zetMetricMetricProgrammableTest : public ::testing::Test {
165165
}
166166

167167
void destroy_metric_group_handles_list(
168-
std::vector<zet_metric_group_handle_t> metric_group_handles_list) {
168+
std::vector<zet_metric_group_handle_t> &metric_group_handles_list) {
169169
LOG_DEBUG << "ENTER destroy_metric_group_handles_list of size "
170170
<< metric_group_handles_list.size();
171171
for (auto metric_group_handle : metric_group_handles_list) {
@@ -175,6 +175,7 @@ class zetMetricMetricProgrammableTest : public ::testing::Test {
175175
EXPECT_EQ(result, ZE_RESULT_SUCCESS)
176176
<< "metric group destroy on handle has failed";
177177
}
178+
metric_group_handles_list.resize(0);
178179
LOG_DEBUG << "LEAVE destroy_metric_group_handles_list";
179180
}
180181
};
@@ -188,7 +189,7 @@ TEST_F(
188189
<< "There are no devices found that support metric programmable";
189190
}
190191

191-
for (auto device_with_metric_programmable_groups :
192+
for (auto &device_with_metric_programmable_groups :
192193
metric_programmable_lists_with_devices) {
193194

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

213-
for (auto device_with_metric_programmable_groups :
214+
for (auto &device_with_metric_programmable_groups :
214215
metric_programmable_lists_with_devices) {
215216

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

330-
for (auto device_with_metric_programmable_groups :
331+
for (auto &device_with_metric_programmable_groups :
331332
metric_programmable_lists_with_devices) {
332333

333334
LOG_INFO << "description of the device being tested: "
@@ -351,7 +352,7 @@ TEST_F(
351352
metric_programmable_handle, param_infos,
352353
metric_programmable_param_info_limit);
353354
ASSERT_GT(param_infos.size(), 0u);
354-
for (auto param_info : param_infos) {
355+
for (auto &param_info : param_infos) {
355356
bool success;
356357
std::string type_string;
357358
std::string value_info_type_string;
@@ -381,7 +382,7 @@ TEST_F(
381382
<< "There are no devices found that support metric programmable";
382383
}
383384

384-
for (auto device_with_metric_programmable_groups :
385+
for (auto &device_with_metric_programmable_groups :
385386
metric_programmable_lists_with_devices) {
386387

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

408409
uint32_t param_info_ordinal = 0;
409410
ASSERT_GT(param_infos.size(), 0u);
410-
for (auto param_info : param_infos) {
411+
for (auto &param_info : param_infos) {
411412
bool success;
412413
std::string type_string;
413414
std::string value_info_type_string;
@@ -446,7 +447,7 @@ TEST_F(
446447
<< "There are no devices found that support metric programmable";
447448
}
448449

449-
for (auto device_with_metric_programmable_groups :
450+
for (auto &device_with_metric_programmable_groups :
450451
metric_programmable_lists_with_devices) {
451452

452453
LOG_INFO << "description of the device being tested: "
@@ -479,7 +480,7 @@ TEST_F(
479480

480481
uint32_t param_info_index = 0;
481482
ASSERT_GT(param_infos.size(), 0u);
482-
for (auto param_info : param_infos) {
483+
for (auto &param_info : param_infos) {
483484
parameter_values[param_info_index].value = param_info.defaultValue;
484485
param_info_index++;
485486
}
@@ -505,7 +506,7 @@ TEST_F(
505506
<< "There are no devices found that support metric programmable";
506507
}
507508

508-
for (auto device_with_metric_programmable_groups :
509+
for (auto &device_with_metric_programmable_groups :
509510
metric_programmable_lists_with_devices) {
510511

511512
LOG_INFO << "description of the device being tested: "
@@ -538,7 +539,7 @@ TEST_F(
538539

539540
uint32_t param_info_index = 0;
540541
ASSERT_GT(param_infos.size(), 0u);
541-
for (auto param_info : param_infos) {
542+
for (auto &param_info : param_infos) {
542543
parameter_values[param_info_index].value = param_info.defaultValue;
543544
param_info_index++;
544545
}

conformance_tests/tools/metrics/src/test_metric_tracer.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ TEST_F(
7171
GTEST_SKIP()
7272
<< "No devices that have metric groups of type Tracer were found";
7373
}
74-
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
74+
for (auto &device_with_metric_group_handles :
75+
tracer_supporting_devices_list) {
7576
device = device_with_metric_group_handles.device;
7677
ze_result_t result;
7778

@@ -125,7 +126,8 @@ TEST_F(
125126
GTEST_SKIP()
126127
<< "No devices that have metric groups of type Tracer were found";
127128
}
128-
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
129+
for (auto &device_with_metric_group_handles :
130+
tracer_supporting_devices_list) {
129131
device = device_with_metric_group_handles.device;
130132
ze_result_t result;
131133

@@ -193,7 +195,8 @@ TEST_F(
193195
GTEST_SKIP()
194196
<< "No devices that have metric groups of type Tracer were found";
195197
}
196-
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
198+
for (auto &device_with_metric_group_handles :
199+
tracer_supporting_devices_list) {
197200
device = device_with_metric_group_handles.device;
198201

199202
lzt::display_device_properties(device);
@@ -362,7 +365,8 @@ TEST_P(
362365
GTEST_SKIP()
363366
<< "No devices that have metric groups of type Tracer were found";
364367
}
365-
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
368+
for (auto &device_with_metric_group_handles :
369+
tracer_supporting_devices_list) {
366370
device = device_with_metric_group_handles.device;
367371

368372
lzt::display_device_properties(device);
@@ -552,7 +556,8 @@ TEST_F(zetMetricTracerTest,
552556
GTEST_SKIP()
553557
<< "No devices that have metric groups of type Tracer were found";
554558
}
555-
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
559+
for (auto &device_with_metric_group_handles :
560+
tracer_supporting_devices_list) {
556561
device = device_with_metric_group_handles.device;
557562

558563
lzt::display_device_properties(device);
@@ -601,7 +606,8 @@ TEST_F(zetMetricTracerTest,
601606
GTEST_SKIP()
602607
<< "No devices that have metric groups of type Tracer were found";
603608
}
604-
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
609+
for (auto &device_with_metric_group_handles :
610+
tracer_supporting_devices_list) {
605611
device = device_with_metric_group_handles.device;
606612

607613
lzt::display_device_properties(device);
@@ -698,7 +704,8 @@ TEST_F(
698704
GTEST_SKIP()
699705
<< "No devices that have metric groups of type Tracer were found";
700706
}
701-
for (auto device_with_metric_group_handles : tracer_supporting_devices_list) {
707+
for (auto &device_with_metric_group_handles :
708+
tracer_supporting_devices_list) {
702709
device = device_with_metric_group_handles.device;
703710
ze_result_t result;
704711

utils/test_harness/tools/src/test_harness_metric.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ void verify_typed_metric_value(zet_typed_value_t result,
669669
break;
670670
default:
671671
ADD_FAILURE() << "Unexpected value type returned for metric query";
672+
break;
672673
}
673674
}
674675

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

1065-
for (auto group_info : metric_group_info_list) {
1066+
for (auto &group_info : metric_group_info_list) {
10661067

10671068
auto it = domain_map.find(group_info.domain);
10681069
if (it == domain_map.end()) {
@@ -1073,7 +1074,7 @@ void generate_activatable_metric_group_list_for_device(
10731074
}
10741075
}
10751076

1076-
for (auto map_entry : domain_map) {
1077+
for (auto &map_entry : domain_map) {
10771078
activatable_metric_group_list.push_back(map_entry.second);
10781079
}
10791080
}
@@ -1138,7 +1139,7 @@ void generate_device_list_with_activatable_metric_group_handles(
11381139
activatable_metric_group_handle_list_for_device_t list_entry;
11391140
list_entry.device = device;
11401141
list_entry.activatable_metric_group_handle_list =
1141-
activatable_metric_group_handle_list;
1142+
std::move(activatable_metric_group_handle_list);
11421143
activatable_metric_group_handles_with_devices_list.push_back(list_entry);
11431144
}
11441145
LOG_DEBUG << "LEAVE generate_activatable_devices_list";
@@ -1192,7 +1193,7 @@ void generate_device_list_with_metric_programmable_handles(
11921193

11931194
metric_programmable_handle_list_for_device list;
11941195
list.device = device;
1195-
list.device_description = device_description;
1196+
list.device_description = std::move(device_description);
11961197
list.metric_programmable_handle_count = metric_programmable_handle_count;
11971198
list.metric_programmable_handles_for_device = {
11981199
metric_programmable_handles.begin(),
@@ -1240,6 +1241,7 @@ bool programmable_param_info_type_to_string(
12401241

12411242
default:
12421243
param_info_type_is_valid = false;
1244+
break;
12431245
}
12441246
return param_info_type_is_valid;
12451247
}
@@ -1312,6 +1314,7 @@ bool programmable_param_info_value_info_type_to_string(
13121314
"contains an fp64 that is not a number";
13131315
value_info_type_string = "ZET_VALUE_INFO_TYPE_EXP_FLOAT64_RANGE";
13141316
oss << param_info.defaultValue.fp64;
1317+
break;
13151318

13161319
default:
13171320
EXPECT_TRUE(false)
@@ -1417,7 +1420,7 @@ void generate_param_info_exp_list_from_metric_programmable(
14171420

14181421
param_infos.resize(metric_programmable_properties.parameterCount);
14191422

1420-
for (auto parameter_info : param_infos) {
1423+
for (auto &parameter_info : param_infos) {
14211424
parameter_info.stype =
14221425
ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_INFO_EXP;
14231426
parameter_info.pNext = nullptr;
@@ -1518,13 +1521,14 @@ void generate_param_value_info_list_from_param_info(
15181521
info->stype = ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_VALUE_INFO_EXP;
15191522
info->pNext = nullptr;
15201523

1524+
zet_metric_programmable_param_value_info_exp_t *desc =
1525+
&value_info_desc[index];
1526+
desc->stype = static_cast<zet_structure_type_t>(
1527+
ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_VALUE_INFO_EXP);
1528+
desc->pNext = nullptr;
1529+
15211530
if (include_value_info_desc) {
1522-
zet_metric_programmable_param_value_info_exp_t *desc =
1523-
&value_info_desc[index];
15241531
info->pNext = desc;
1525-
desc->pNext = nullptr;
1526-
desc->stype = static_cast<zet_structure_type_t>(
1527-
ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_VALUE_INFO_EXP);
15281532
}
15291533
}
15301534

0 commit comments

Comments
 (0)