diff --git a/src/mdbx.c b/src/mdbx.c index 1ff535b7..c5148a80 100644 --- a/src/mdbx.c +++ b/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