From 4708e0cf79b186a46f1ac5f300d2ce74eb9272ba Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Thu, 17 Jan 2019 23:09:40 +0300 Subject: [PATCH] mdbx-winfdows: fix returning negative value on failure. Change-Id: Iaf5fb1f0cbcc3c14e2d3edf1f57538ecc0dfdf00 --- src/mdbx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mdbx.c b/src/mdbx.c index 5a7ea680..1f9357d2 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -1,4 +1,4 @@ -/* +/* * Copyright 2015-2018 Leonid Yuriev * and other libmdbx authors: please see AUTHORS file. * All rights reserved. @@ -5496,7 +5496,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; } @@ -12466,7 +12466,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; @@ -12796,7 +12796,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; @@ -13515,7 +13515,7 @@ __cold intptr_t mdbx_limits_keysize_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; return mdbx_maxkey(mdbx_nodemax(pagesize)); } @@ -13530,7 +13530,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; } @@ -13541,7 +13541,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 @@ -13554,7 +13554,7 @@ __cold intptr_t mdbx_limits_txnsize_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; return pagesize * (MDBX_DPL_TXNFULL - 1); }