Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pmem2: fix valgrind instrumentation in pmem2_map_from_exisiting #5605

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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