Skip to content

Commit 6a0e91e

Browse files
authored
Fix unused variable warning with Clang and --enable-address-sanitizer. (#3848)
1 parent cb54980 commit 6a0e91e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

runtime/unix.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,13 @@ static void* mmap_named(void* addr, size_t length, int prot, int flags,
540540
void *caml_plat_mem_map(uintnat size, uintnat caml_flags, const char* name)
541541
{
542542
uintnat alignment = caml_plat_hugepagesize;
543-
uintnat reserve_only = caml_flags & CAML_MAP_RESERVE_ONLY;
544-
uintnat no_hugetlb = caml_flags & CAML_MAP_NO_HUGETLB;
545543
#ifdef WITH_ADDRESS_SANITIZER
546544
return aligned_alloc(alignment, (size + (alignment - 1)) & ~(alignment - 1));
547545
#else
546+
uintnat reserve_only = caml_flags & CAML_MAP_RESERVE_ONLY;
547+
uintnat no_hugetlb = caml_flags & CAML_MAP_NO_HUGETLB;
548+
(void)no_hugetlb; /* avoid unused variable warning */
549+
548550
void* mem;
549551
int prot = reserve_only ? PROT_NONE : (PROT_READ | PROT_WRITE);
550552
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
@@ -614,7 +616,9 @@ static void* map_fixed(void* mem, uintnat size, int prot, const char* name)
614616
void *caml_plat_mem_map(uintnat size, uintnat flags, const char* name)
615617
{
616618
void* mem;
617-
uintnat reserve_only = flags & CAML_MAP_RESERVE_ONLY;
619+
uintnat reserve_only = caml_flags & CAML_MAP_RESERVE_ONLY;
620+
uintnat no_hugetlb = caml_flags & CAML_MAP_NO_HUGETLB;
621+
(void)no_hugetlb; /* Not used on Cygwin */
618622

619623
mem = mmap(0, size, reserve_only ? PROT_NONE : (PROT_READ | PROT_WRITE),
620624
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

0 commit comments

Comments
 (0)