diff --git a/test/gtest/uct/uct_test.cc b/test/gtest/uct/uct_test.cc index b963b7200b0..9f5d546544e 100644 --- a/test/gtest/uct/uct_test.cc +++ b/test/gtest/uct/uct_test.cc @@ -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, @@ -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; @@ -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(); }