mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-10 03:44:12 +08:00
mdbx-windows: backport - fix returning negative value on failure.
Change-Id: Iaf5fb1f0cbcc3c14e2d3edf1f57538ecc0dfdf00
This commit is contained in:
parent
4f79e3756c
commit
ba00b597a7
21
src/mdbx.c
21
src/mdbx.c
@ -5024,7 +5024,7 @@ fail:
|
||||
|
||||
int __cold mdbx_env_get_maxkeysize(MDBX_env *env) {
|
||||
if (!env || env->me_signature != MDBX_ME_SIGNATURE || !env->me_maxkey_limit)
|
||||
return -MDBX_EINVAL;
|
||||
return (MDBX_EINVAL > 0) ? -MDBX_EINVAL : MDBX_EINVAL;
|
||||
return env->me_maxkey_limit;
|
||||
}
|
||||
|
||||
@ -11538,7 +11538,7 @@ int __cold mdbx_reader_list(MDBX_env *env, MDBX_msg_func *func, void *ctx) {
|
||||
int rc = 0, first = 1;
|
||||
|
||||
if (unlikely(!env || !func))
|
||||
return -MDBX_EINVAL;
|
||||
return (MDBX_EINVAL > 0) ? -MDBX_EINVAL : MDBX_EINVAL;
|
||||
|
||||
if (unlikely(env->me_signature != MDBX_ME_SIGNATURE))
|
||||
return MDBX_EBADSIGN;
|
||||
@ -11848,7 +11848,7 @@ __attribute__((no_sanitize_thread, noinline))
|
||||
int mdbx_txn_straggler(MDBX_txn *txn, int *percent)
|
||||
{
|
||||
if (unlikely(!txn))
|
||||
return -MDBX_EINVAL;
|
||||
return (MDBX_EINVAL > 0) ? -MDBX_EINVAL : MDBX_EINVAL;
|
||||
|
||||
if (unlikely(txn->mt_signature != MDBX_MT_SIGNATURE))
|
||||
return MDBX_EBADSIGN;
|
||||
@ -12501,6 +12501,17 @@ int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result,
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
__cold intptr_t mdbx_limits_keysize_max(intptr_t pagesize) {
|
||||
if (pagesize < 1)
|
||||
pagesize = (intptr_t)mdbx_syspagesize();
|
||||
else if (unlikely(pagesize < (intptr_t)MIN_PAGESIZE ||
|
||||
pagesize > (intptr_t)MAX_PAGESIZE ||
|
||||
!mdbx_is_power2((size_t)pagesize)))
|
||||
return (MDBX_EINVAL > 0) ? -MDBX_EINVAL : MDBX_EINVAL;
|
||||
|
||||
return mdbx_maxkey(mdbx_nodemax(pagesize));
|
||||
}
|
||||
|
||||
__cold int mdbx_limits_pgsize_min(void) { return MIN_PAGESIZE; }
|
||||
|
||||
__cold int mdbx_limits_pgsize_max(void) { return MAX_PAGESIZE; }
|
||||
@ -12511,7 +12522,7 @@ __cold intptr_t mdbx_limits_dbsize_min(intptr_t pagesize) {
|
||||
else if (unlikely(pagesize < (intptr_t)MIN_PAGESIZE ||
|
||||
pagesize > (intptr_t)MAX_PAGESIZE ||
|
||||
!mdbx_is_power2((size_t)pagesize)))
|
||||
return -MDBX_EINVAL;
|
||||
return (MDBX_EINVAL > 0) ? -MDBX_EINVAL : MDBX_EINVAL;
|
||||
|
||||
return MIN_PAGENO * pagesize;
|
||||
}
|
||||
@ -12522,7 +12533,7 @@ __cold intptr_t mdbx_limits_dbsize_max(intptr_t pagesize) {
|
||||
else if (unlikely(pagesize < (intptr_t)MIN_PAGESIZE ||
|
||||
pagesize > (intptr_t)MAX_PAGESIZE ||
|
||||
!mdbx_is_power2((size_t)pagesize)))
|
||||
return -MDBX_EINVAL;
|
||||
return (MDBX_EINVAL > 0) ? -MDBX_EINVAL : MDBX_EINVAL;
|
||||
|
||||
const uint64_t limit = MAX_PAGENO * (uint64_t)pagesize;
|
||||
return (limit < (intptr_t)MAX_MAPSIZE) ? (intptr_t)limit
|
||||
|
Loading…
x
Reference in New Issue
Block a user