Skip to content

Commit

Permalink
Merge pull request #5605 from lplewa/stable-1.12
Browse files Browse the repository at this point in the history
pmem2: fix valgrind instrumentation in pmem2_map_from_exisiting
  • Loading branch information
janekmi authored May 10, 2023
2 parents 59281bb + aea64b2 commit 8b16695
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/libpmem2/map_posix.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2019-2021, Intel Corporation */
/* Copyright 2019-2023, Intel Corporation */

/*
* map_posix.c -- pmem2_map (POSIX)
Expand Down Expand Up @@ -590,14 +590,17 @@ pmem2_map_delete(struct pmem2_map **map_ptr)
if (ret)
return ret;

#ifndef _WIN32
if (map->source.type == PMEM2_SOURCE_FD) {
VALGRIND_REMOVE_PMEM_MAPPING(map_addr, map_len);
}
#endif
/*
* when reserved_length==0 mapping is created by pmem2_map_from_existing
* such mappings are provided by the users and shouldn't be unmapped
* by pmem2.
*/
if (map->reserved_length) {
VALGRIND_REMOVE_PMEM_MAPPING(map_addr, map_len);

if (rsv) {
void *rsv_addr = pmem2_vm_reservation_get_address(rsv);
size_t rsv_offset = (size_t)map_addr - (size_t)rsv_addr;
Expand Down
6 changes: 2 additions & 4 deletions src/test/unittest/ut_file.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2020, Intel Corporation */
/* Copyright 2014-2023, Intel Corporation */

/*
* ut_file.c -- unit test file operations
Expand Down Expand Up @@ -369,9 +369,7 @@ ut_file_map(const char *file, int line, const char *func, int fd, size_t size)
void *
ut_file_map(const char *file, int line, const char *func, int fd, size_t size)
{
void *addr = NULL;
ut_mmap(file, line, func, addr, size, PROT_READ | PROT_WRITE,
return ut_mmap(file, line, func, NULL, size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
return addr;
}
#endif

0 comments on commit 8b16695

Please sign in to comment.