mdbx: fix minor warnings.

Change-Id: Iaa614a7d4325d3de6d863c20020c62954da7a1bf
This commit is contained in:
Leonid Yuriev 2019-10-25 22:56:25 +03:00
parent a0ec89e468
commit c694325ab7
5 changed files with 24 additions and 24 deletions

4
mdbx.h
View File

@ -834,8 +834,8 @@ typedef void MDBX_assert_func(const MDBX_env *env, const char *msg,
LIBMDBX_API int mdbx_env_set_assert(MDBX_env *env, MDBX_assert_func *func); LIBMDBX_API int mdbx_env_set_assert(MDBX_env *env, MDBX_assert_func *func);
/* FIXME: Complete description */ /* FIXME: Complete description */
LIBMDBX_API char *mdbx_dump_val(const MDBX_val *key, char *const buf, LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf,
const size_t bufsize); const size_t bufsize);
/**** THE FILES **************************************************************** /**** THE FILES ****************************************************************
* At the file system level, the environment corresponds to a pair of files. */ * At the file system level, the environment corresponds to a pair of files. */

View File

@ -2203,8 +2203,8 @@ void __cold mdbx_debug_log(int level, const char *function, int line,
} }
/* Dump a key in ascii or hexadecimal. */ /* Dump a key in ascii or hexadecimal. */
char *mdbx_dump_val(const MDBX_val *key, char *const buf, const char *mdbx_dump_val(const MDBX_val *key, char *const buf,
const size_t bufsize) { const size_t bufsize) {
if (!key) if (!key)
return "<null>"; return "<null>";
if (!buf || bufsize < 4) if (!buf || bufsize < 4)
@ -2249,7 +2249,8 @@ char *mdbx_dump_val(const MDBX_val *key, char *const buf,
LY: debug stuff */ LY: debug stuff */
static const char *mdbx_leafnode_type(MDBX_node *n) { static const char *mdbx_leafnode_type(MDBX_node *n) {
static char *const tp[2][2] = {{"", ": DB"}, {": sub-page", ": sub-DB"}}; static const char *const tp[2][2] = {{"", ": DB"},
{": sub-page", ": sub-DB"}};
return F_ISSET(node_flags(n), F_BIGDATA) return F_ISSET(node_flags(n), F_BIGDATA)
? ": overflow page" ? ": overflow page"
: tp[F_ISSET(node_flags(n), F_DUPDATA)] : tp[F_ISSET(node_flags(n), F_DUPDATA)]
@ -10625,7 +10626,7 @@ new_sub:
size_t ecount; size_t ecount;
put_sub: put_sub:
xdata.iov_len = 0; xdata.iov_len = 0;
xdata.iov_base = ""; xdata.iov_base = nullptr;
MDBX_node *node = page_node(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]); MDBX_node *node = page_node(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
if (flags & MDBX_CURRENT) { if (flags & MDBX_CURRENT) {
xflags = (flags & MDBX_NODUPDATA) xflags = (flags & MDBX_NODUPDATA)
@ -10916,7 +10917,7 @@ static __pure_function __inline size_t branch_size(MDBX_env *env,
if (unlikely(sz > env->me_nodemax)) { if (unlikely(sz > env->me_nodemax)) {
/* put on overflow page */ /* put on overflow page */
/* not implemented */ /* not implemented */
mdbx_assert_fail(env, "INDXSIZE(key) <= env->me_nodemax", __FUNCTION__, mdbx_assert_fail(env, "INDXSIZE(key) <= env->me_nodemax", __func__,
__LINE__); __LINE__);
sz = sz - key->iov_len + sizeof(pgno_t); sz = sz - key->iov_len + sizeof(pgno_t);
} }

View File

@ -349,7 +349,7 @@ typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define mdbx_func_ __func__ # define mdbx_func_ __func__
#elif (defined(__GNUC__) && __GNUC__ >= 2) || defined(__clang__) || defined(_MSC_VER) #elif (defined(__GNUC__) && __GNUC__ >= 2) || defined(__clang__) || defined(_MSC_VER)
# define mdbx_func_ __FUNCTION__ # define mdbx_func_ __func__
#else #else
# define mdbx_func_ "<mdbx_unknown>" # define mdbx_func_ "<mdbx_unknown>"
#endif #endif

View File

@ -1090,8 +1090,7 @@ MDBX_INTERNAL_FUNC void mdbx_assert_fail(const MDBX_env *env, const char *msg,
#define mdbx_debug_extra(fmt, ...) \ #define mdbx_debug_extra(fmt, ...) \
do { \ do { \
if (mdbx_log_enabled(MDBX_LOG_EXTRA)) \ if (mdbx_log_enabled(MDBX_LOG_EXTRA)) \
mdbx_debug_log(MDBX_LOG_EXTRA, __FUNCTION__, __LINE__, fmt, \ mdbx_debug_log(MDBX_LOG_EXTRA, __func__, __LINE__, fmt, ##__VA_ARGS__); \
##__VA_ARGS__); \
} while (0) } while (0)
#define mdbx_debug_extra_print(fmt, ...) \ #define mdbx_debug_extra_print(fmt, ...) \
@ -1103,14 +1102,14 @@ MDBX_INTERNAL_FUNC void mdbx_assert_fail(const MDBX_env *env, const char *msg,
#define mdbx_trace(fmt, ...) \ #define mdbx_trace(fmt, ...) \
do { \ do { \
if (mdbx_log_enabled(MDBX_LOG_TRACE)) \ if (mdbx_log_enabled(MDBX_LOG_TRACE)) \
mdbx_debug_log(MDBX_LOG_TRACE, __FUNCTION__, __LINE__, fmt "\n", \ mdbx_debug_log(MDBX_LOG_TRACE, __func__, __LINE__, fmt "\n", \
##__VA_ARGS__); \ ##__VA_ARGS__); \
} while (0) } while (0)
#define mdbx_debug(fmt, ...) \ #define mdbx_debug(fmt, ...) \
do { \ do { \
if (mdbx_log_enabled(MDBX_LOG_DEBUG)) \ if (mdbx_log_enabled(MDBX_LOG_DEBUG)) \
mdbx_debug_log(MDBX_LOG_DEBUG, __FUNCTION__, __LINE__, fmt "\n", \ mdbx_debug_log(MDBX_LOG_DEBUG, __func__, __LINE__, fmt "\n", \
##__VA_ARGS__); \ ##__VA_ARGS__); \
} while (0) } while (0)
@ -1123,39 +1122,38 @@ MDBX_INTERNAL_FUNC void mdbx_assert_fail(const MDBX_env *env, const char *msg,
#define mdbx_verbose(fmt, ...) \ #define mdbx_verbose(fmt, ...) \
do { \ do { \
if (mdbx_log_enabled(MDBX_LOG_VERBOSE)) \ if (mdbx_log_enabled(MDBX_LOG_VERBOSE)) \
mdbx_debug_log(MDBX_LOG_VERBOSE, __FUNCTION__, __LINE__, fmt "\n", \ mdbx_debug_log(MDBX_LOG_VERBOSE, __func__, __LINE__, fmt "\n", \
##__VA_ARGS__); \ ##__VA_ARGS__); \
} while (0) } while (0)
#define mdbx_notice(fmt, ...) \ #define mdbx_notice(fmt, ...) \
do { \ do { \
if (mdbx_log_enabled(MDBX_LOG_NOTICE)) \ if (mdbx_log_enabled(MDBX_LOG_NOTICE)) \
mdbx_debug_log(MDBX_LOG_NOTICE, __FUNCTION__, __LINE__, fmt "\n", \ mdbx_debug_log(MDBX_LOG_NOTICE, __func__, __LINE__, fmt "\n", \
##__VA_ARGS__); \ ##__VA_ARGS__); \
} while (0) } while (0)
#define mdbx_warning(fmt, ...) \ #define mdbx_warning(fmt, ...) \
do { \ do { \
if (mdbx_log_enabled(MDBX_LOG_WARN)) \ if (mdbx_log_enabled(MDBX_LOG_WARN)) \
mdbx_debug_log(MDBX_LOG_WARN, __FUNCTION__, __LINE__, fmt "\n", \ mdbx_debug_log(MDBX_LOG_WARN, __func__, __LINE__, fmt "\n", \
##__VA_ARGS__); \ ##__VA_ARGS__); \
} while (0) } while (0)
#define mdbx_error(fmt, ...) \ #define mdbx_error(fmt, ...) \
do { \ do { \
if (mdbx_log_enabled(MDBX_LOG_ERROR)) \ if (mdbx_log_enabled(MDBX_LOG_ERROR)) \
mdbx_debug_log(MDBX_LOG_ERROR, __FUNCTION__, __LINE__, fmt "\n", \ mdbx_debug_log(MDBX_LOG_ERROR, __func__, __LINE__, fmt "\n", \
##__VA_ARGS__); \ ##__VA_ARGS__); \
} while (0) } while (0)
#define mdbx_fatal(fmt, ...) \ #define mdbx_fatal(fmt, ...) \
mdbx_debug_log(MDBX_LOG_FATAL, __FUNCTION__, __LINE__, fmt "\n", \ mdbx_debug_log(MDBX_LOG_FATAL, __func__, __LINE__, fmt "\n", ##__VA_ARGS__);
##__VA_ARGS__);
#define mdbx_ensure_msg(env, expr, msg) \ #define mdbx_ensure_msg(env, expr, msg) \
do { \ do { \
if (unlikely(!(expr))) \ if (unlikely(!(expr))) \
mdbx_assert_fail(env, msg, __FUNCTION__, __LINE__); \ mdbx_assert_fail(env, msg, __func__, __LINE__); \
} while (0) } while (0)
#define mdbx_ensure(env, expr) mdbx_ensure_msg(env, expr, #expr) #define mdbx_ensure(env, expr) mdbx_ensure_msg(env, expr, #expr)

View File

@ -241,17 +241,18 @@ MDBX_INTERNAL_FUNC __cold void mdbx_panic(const char *fmt, ...) {
char *message = nullptr; char *message = nullptr;
const int num = mdbx_vasprintf(&message, fmt, ap); const int num = mdbx_vasprintf(&message, fmt, ap);
va_end(ap); va_end(ap);
if (num < 1 || !message) const char *const const_message =
message = "<troubles with panic-message preparation>"; (num < 1 || !message) ? "<troubles with panic-message preparation>"
: message;
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
OutputDebugStringA("\r\nMDBX-PANIC: "); OutputDebugStringA("\r\nMDBX-PANIC: ");
OutputDebugStringA(message); OutputDebugStringA(const_message);
if (IsDebuggerPresent()) if (IsDebuggerPresent())
DebugBreak(); DebugBreak();
FatalExit(ERROR_UNHANDLED_ERROR); FatalExit(ERROR_UNHANDLED_ERROR);
#else #else
__assert_fail(message, "mdbx", 0, "panic"); __assert_fail(const_message, "mdbx", 0, "panic");
abort(); abort();
#endif #endif
} }
@ -1325,7 +1326,7 @@ MDBX_INTERNAL_FUNC __cold void mdbx_osal_jitter(bool tiny) {
#elif defined(__APPLE__) || defined(__MACH__) #elif defined(__APPLE__) || defined(__MACH__)
#include <mach/mach_time.h> #include <mach/mach_time.h>
#elif defined(__linux__) || defined(__gnu_linux__) #elif defined(__linux__) || defined(__gnu_linux__)
static __cold clockid_t choice_monoclock() { static __cold clockid_t choice_monoclock(void) {
struct timespec probe; struct timespec probe;
#if defined(CLOCK_BOOTTIME) #if defined(CLOCK_BOOTTIME)
if (clock_gettime(CLOCK_BOOTTIME, &probe) == 0) if (clock_gettime(CLOCK_BOOTTIME, &probe) == 0)