Skip to content

Commit 54aff86

Browse files
authored
Merge pull request #1133 from kswiecicki/coverity-fixes
Coverity fixes
2 parents 329dda6 + b92b60d commit 54aff86

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

source/common/umf_pools/disjoint_pool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ void *DisjointPool::malloc(size_t size) { // For full-slab allocations indicates
913913
auto Ptr = impl->allocate(size, FromPool);
914914

915915
if (impl->getParams().PoolTrace > 2) {
916-
auto MT = impl->getParams().name;
916+
const auto &MT = impl->getParams().name;
917917
std::cout << "Allocated " << std::setw(8) << size << " " << MT
918918
<< " bytes from " << (FromPool ? "Pool" : "Provider") << " ->"
919919
<< Ptr << std::endl;
@@ -938,7 +938,7 @@ void *DisjointPool::aligned_malloc(size_t size, size_t alignment) {
938938
auto Ptr = impl->allocate(size, alignment, FromPool);
939939

940940
if (impl->getParams().PoolTrace > 2) {
941-
auto MT = impl->getParams().name;
941+
const auto &MT = impl->getParams().name;
942942
std::cout << "Allocated " << std::setw(8) << size << " " << MT
943943
<< " bytes aligned at " << alignment << " from "
944944
<< (FromPool ? "Pool" : "Provider") << " ->" << Ptr
@@ -957,7 +957,7 @@ enum umf_result_t DisjointPool::free(void *ptr) try {
957957
impl->deallocate(ptr, ToPool);
958958

959959
if (impl->getParams().PoolTrace > 2) {
960-
auto MT = impl->getParams().name;
960+
const auto &MT = impl->getParams().name;
961961
std::cout << "Freed " << MT << " " << ptr << " to "
962962
<< (ToPool ? "Pool" : "Provider")
963963
<< ", Current total pool size "

source/loader/ur_adapter_registry.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class AdapterRegistry {
4141
}
4242

4343
if (exists) {
44-
adaptersLoadPaths.emplace_back(std::vector{path});
44+
adaptersLoadPaths.emplace_back(
45+
std::vector{std::move(path)});
4546
} else {
4647
logger::warning(
4748
"Detected nonexistent path {} in environmental "
@@ -164,12 +165,12 @@ class AdapterRegistry {
164165

165166
auto adapterNamePathOpt = getAdapterNameAsPath(adapterName);
166167
if (adapterNamePathOpt.has_value()) {
167-
auto adapterNamePath = adapterNamePathOpt.value();
168+
const auto &adapterNamePath = adapterNamePathOpt.value();
168169
loadPaths.emplace_back(adapterNamePath);
169170
}
170171

171172
if (loaderLibPathOpt.has_value()) {
172-
auto loaderLibPath = loaderLibPathOpt.value();
173+
const auto &loaderLibPath = loaderLibPathOpt.value();
173174
loadPaths.emplace_back(loaderLibPath / adapterName);
174175
}
175176

test/loader/adapter_registry/search_order.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "fixtures.hpp"
77

88
template <typename P>
9-
void assertRegistryPathSequence(std::vector<fs::path> testAdapterPaths,
9+
void assertRegistryPathSequence(const std::vector<fs::path> &testAdapterPaths,
1010
P predicate) {
1111
static size_t assertIndex = 0;
1212

@@ -24,7 +24,7 @@ TEST_F(adapterRegSearchTest, testSearchOrder) {
2424
auto it = std::find_if(registry.cbegin(), registry.cend(), hasTestLibName);
2525
ASSERT_NE(it, registry.end());
2626

27-
auto testAdapterPaths = *it;
27+
const auto &testAdapterPaths = *it;
2828
assertRegistryPathSequence(testAdapterPaths, isTestEnvPath);
2929
#ifndef _WIN32
3030
assertRegistryPathSequence(testAdapterPaths, isTestLibName);

test/usm/usmPoolManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ TEST_P(urUsmPoolManagerTest, poolManagerInsertExisting) {
9090
auto [ret, manager] = usm::pool_manager<usm::pool_descriptor>::create();
9191
ASSERT_EQ(ret, UR_RESULT_SUCCESS);
9292

93-
auto desc = poolDescriptors[0];
93+
const auto &desc = poolDescriptors[0];
9494

9595
auto pool = nullPoolCreate();
9696
ASSERT_NE(pool, nullptr);

0 commit comments

Comments
 (0)