Skip to content

Commit

Permalink
UCT/TEST: Fix coverity by adding m_iov and m_rkey initialization to m…
Browse files Browse the repository at this point in the history
…apped_buffer move ctor
  • Loading branch information
ivankochin committed Dec 27, 2023
1 parent 173511d commit 4bb8d60
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions test/gtest/uct/uct_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1377,8 +1377,14 @@ void uct_test::mapped_buffer::reset()
m_mem.length = 0;
m_buf = NULL;
m_end = NULL;
m_iov.buffer = NULL;
m_iov.length = 0;
m_iov.count = 1;
m_iov.stride = 0;
m_iov.memh = UCT_MEM_HANDLE_NULL;
m_rkey.rkey = UCT_INVALID_RKEY;
m_rkey.handle = NULL;
m_rkey.type = NULL;
}

uct_test::mapped_buffer::mapped_buffer(size_t size, uint64_t seed,
Expand All @@ -1387,25 +1393,27 @@ uct_test::mapped_buffer::mapped_buffer(size_t size, uint64_t seed,
unsigned mem_flags) :
m_entity(entity)
{
if (size > 0) {
size_t alloc_size = size + offset;
if (mem_type == UCS_MEMORY_TYPE_HOST) {
m_entity.mem_alloc_host(alloc_size, mem_flags, &m_mem);
} else {
m_mem.method = UCT_ALLOC_METHOD_LAST;
m_mem.address = mem_buffer::allocate(alloc_size, mem_type);
m_mem.length = alloc_size;
m_mem.mem_type = mem_type;
m_mem.memh = UCT_MEM_HANDLE_NULL;
m_mem.md = NULL;
m_entity.mem_type_reg(&m_mem, mem_flags);
}
m_buf = (char*)m_mem.address + offset;
m_end = (char*)m_buf + size;
pattern_fill(seed);
} else {
if (size == 0) {
reset();
return;
}

size_t alloc_size = size + offset;
if (mem_type == UCS_MEMORY_TYPE_HOST) {
m_entity.mem_alloc_host(alloc_size, mem_flags, &m_mem);
} else {
m_mem.method = UCT_ALLOC_METHOD_LAST;
m_mem.address = mem_buffer::allocate(alloc_size, mem_type);
m_mem.length = alloc_size;
m_mem.mem_type = mem_type;
m_mem.memh = UCT_MEM_HANDLE_NULL;
m_mem.md = NULL;
m_entity.mem_type_reg(&m_mem, mem_flags);
}

m_buf = (char*)m_mem.address + offset;
m_end = (char*)m_buf + size;
pattern_fill(seed);
m_iov.buffer = ptr();
m_iov.length = length();
m_iov.count = 1;
Expand All @@ -1417,19 +1425,9 @@ uct_test::mapped_buffer::mapped_buffer(size_t size, uint64_t seed,
}

uct_test::mapped_buffer::mapped_buffer(mapped_buffer &&other) :
m_entity(other.m_entity)
m_entity(other.m_entity), m_buf(other.m_buf), m_end(other.m_end),
m_rkey(other.m_rkey), m_mem(other.m_mem), m_iov(other.m_iov)
{
m_mem.method = other.m_mem.method;
m_mem.address = other.m_mem.address;
m_mem.md = other.m_mem.md;
m_mem.memh = other.m_mem.memh;
m_mem.mem_type = other.m_mem.mem_type;
m_mem.length = other.m_mem.length;
m_buf = other.m_buf;
m_end = other.m_end;
m_rkey.rkey = other.m_rkey.rkey;
m_rkey.handle = other.m_rkey.handle;

other.reset();
}

Expand Down

0 comments on commit 4bb8d60

Please sign in to comment.