summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Esser <besser82@fedoraproject.org>2022-11-18 19:39:27 +0100
committerBjörn Esser <besser82@fedoraproject.org>2022-11-18 19:39:27 +0100
commit53cff4b6efe330c146bdb4def3d4e1aef7eb9bd9 (patch)
treebc32fa4ed7589434ad29add835245ed778880f8c
parent05e5705d66fb18c75bfe32bdcd1774248abab2ce (diff)
downloadlibxcrypt-53cff4b6efe330c146bdb4def3d4e1aef7eb9bd9.tar.gz
libxcrypt-53cff4b6efe330c146bdb4def3d4e1aef7eb9bd9.tar.bz2
libxcrypt-53cff4b6efe330c146bdb4def3d4e1aef7eb9bd9.zip
lib/alg-yescrypt-platform.c: Fix -Werror=sign-conversion.
This is a more elegant approach of the previous commit.
-rw-r--r--lib/alg-yescrypt-platform.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/alg-yescrypt-platform.c b/lib/alg-yescrypt-platform.c
index 615a0c6..d68af2d 100644
--- a/lib/alg-yescrypt-platform.c
+++ b/lib/alg-yescrypt-platform.c
@@ -38,7 +38,7 @@ static void *alloc_region(yescrypt_region_t *region, size_t size)
size_t base_size = size;
uint8_t *base, *aligned;
#ifdef MAP_ANON
- int flags =
+ unsigned int flags =
#ifdef MAP_NOCORE
MAP_NOCORE |
#endif
@@ -47,7 +47,7 @@ static void *alloc_region(yescrypt_region_t *region, size_t size)
size_t new_size = size;
const size_t hugepage_mask = (size_t)HUGEPAGE_SIZE - 1;
if (size >= HUGEPAGE_THRESHOLD && size + hugepage_mask >= size) {
- flags |= (int)(MAP_HUGETLB | MAP_HUGE_2MB);
+ flags |= MAP_HUGETLB | MAP_HUGE_2MB;
/*
* Linux's munmap() fails on MAP_HUGETLB mappings if size is not a multiple of
* huge page size, so let's round up to huge page size here.
@@ -55,16 +55,16 @@ static void *alloc_region(yescrypt_region_t *region, size_t size)
new_size = size + hugepage_mask;
new_size &= ~hugepage_mask;
}
- base = mmap(NULL, new_size, PROT_READ | PROT_WRITE, flags, -1, 0);
+ base = mmap(NULL, new_size, PROT_READ | PROT_WRITE, (int)flags, -1, 0);
if (base != MAP_FAILED) {
base_size = new_size;
} else if (flags & MAP_HUGETLB) {
- flags &= ~(int)(MAP_HUGETLB | MAP_HUGE_2MB);
- base = mmap(NULL, size, PROT_READ | PROT_WRITE, flags, -1, 0);
+ flags &= (unsigned int)~(MAP_HUGETLB | MAP_HUGE_2MB);
+ base = mmap(NULL, size, PROT_READ | PROT_WRITE, (int)flags, -1, 0);
}
#else
- base = mmap(NULL, size, PROT_READ | PROT_WRITE, flags, -1, 0);
+ base = mmap(NULL, size, PROT_READ | PROT_WRITE, (int)flags, -1, 0);
#endif
if (base == MAP_FAILED)
base = NULL;