mdbx: fix gcc warning (minor).

This commit is contained in:
Leo Yuriev 2018-03-21 22:46:22 +03:00
parent 3d320253cd
commit 5ce40269b3

View File

@ -4160,7 +4160,7 @@ static int __cold mdbx_read_header(MDBX_env *env, MDBX_meta *meta) {
STATIC_ASSERT(MIN_MAPSIZE < MAX_MAPSIZE); STATIC_ASSERT(MIN_MAPSIZE < MAX_MAPSIZE);
if (mapsize_max > MAX_MAPSIZE || if (mapsize_max > MAX_MAPSIZE ||
MAX_PAGENO < mdbx_roundup2((size_t)mapsize_max, env->me_os_psize) / MAX_PAGENO < mdbx_roundup2((size_t)mapsize_max, env->me_os_psize) /
(uint64_t)page.mp_meta.mm_psize) { (size_t)page.mp_meta.mm_psize) {
const uint64_t used_bytes = const uint64_t used_bytes =
page.mp_meta.mm_geo.next * (uint64_t)page.mp_meta.mm_psize; page.mp_meta.mm_geo.next * (uint64_t)page.mp_meta.mm_psize;
if (page.mp_meta.mm_geo.next - 1 > MAX_PAGENO || if (page.mp_meta.mm_geo.next - 1 > MAX_PAGENO ||
@ -4762,13 +4762,13 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
if (pagesize < 0) { if (pagesize < 0) {
pagesize = env->me_os_psize; pagesize = env->me_os_psize;
if (pagesize > MAX_PAGESIZE) if ((uintptr_t)pagesize > MAX_PAGESIZE)
pagesize = MAX_PAGESIZE; pagesize = MAX_PAGESIZE;
mdbx_assert(env, pagesize >= MIN_PAGESIZE); mdbx_assert(env, (uintptr_t)pagesize >= MIN_PAGESIZE);
} }
} }
if (pagesize < MIN_PAGESIZE || pagesize > MAX_PAGESIZE || if (pagesize < (intptr_t)MIN_PAGESIZE || pagesize > (intptr_t)MAX_PAGESIZE ||
!mdbx_is_power2(pagesize)) { !mdbx_is_power2(pagesize)) {
rc = MDBX_EINVAL; rc = MDBX_EINVAL;
goto bailout; goto bailout;
@ -4802,7 +4802,7 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
size_upper = pagesize * MAX_PAGENO; size_upper = pagesize * MAX_PAGENO;
} }
if (unlikely(size_lower < MIN_MAPSIZE || size_lower > size_upper)) { if (unlikely(size_lower < (intptr_t)MIN_MAPSIZE || size_lower > size_upper)) {
rc = MDBX_EINVAL; rc = MDBX_EINVAL;
goto bailout; goto bailout;
} }
@ -5109,7 +5109,7 @@ static int __cold mdbx_setup_dxb(MDBX_env *env, int lck_rc) {
filesize_before_mmap, filesize_before_mmap,
bytes2pgno(env, (size_t)filesize_before_mmap)); bytes2pgno(env, (size_t)filesize_before_mmap));
} else { } else {
mdbx_notice("filesize mismatch (expect %" PRIuPTR "/%" PRIaPGNO mdbx_notice("filesize mismatch (expect %" PRIuSIZE "/%" PRIaPGNO
", have %" PRIu64 "/%" PRIaPGNO ")", ", have %" PRIu64 "/%" PRIaPGNO ")",
expected_bytes, bytes2pgno(env, expected_bytes), expected_bytes, bytes2pgno(env, expected_bytes),
filesize_before_mmap, filesize_before_mmap,
@ -5125,11 +5125,11 @@ static int __cold mdbx_setup_dxb(MDBX_env *env, int lck_rc) {
if (env->me_flags & MDBX_RDONLY) { if (env->me_flags & MDBX_RDONLY) {
mdbx_notice("ignore filesize mismatch in readonly-mode"); mdbx_notice("ignore filesize mismatch in readonly-mode");
} else { } else {
mdbx_info("resize datafile to %" PRIu64 " bytes, %" PRIaPGNO " pages", mdbx_info("resize datafile to %" PRIuSIZE " bytes, %" PRIaPGNO " pages",
expected_bytes, bytes2pgno(env, expected_bytes)); expected_bytes, bytes2pgno(env, expected_bytes));
err = mdbx_ftruncate(env->me_fd, expected_bytes); err = mdbx_ftruncate(env->me_fd, expected_bytes);
if (unlikely(err != MDBX_SUCCESS)) { if (unlikely(err != MDBX_SUCCESS)) {
mdbx_error("error %d, while resize datafile to %" PRIu64 mdbx_error("error %d, while resize datafile to %" PRIuSIZE
" bytes, %" PRIaPGNO " pages", " bytes, %" PRIaPGNO " pages",
rc, expected_bytes, bytes2pgno(env, expected_bytes)); rc, expected_bytes, bytes2pgno(env, expected_bytes));
return err; return err;