From c694325ab71af88101e1cf003f7f412312fe7630 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Fri, 25 Oct 2019 22:56:25 +0300 Subject: [PATCH] mdbx: fix minor warnings. Change-Id: Iaa614a7d4325d3de6d863c20020c62954da7a1bf --- mdbx.h | 4 ++-- src/elements/core.c | 11 ++++++----- src/elements/defs.h | 2 +- src/elements/internals.h | 20 +++++++++----------- src/elements/osal.c | 11 ++++++----- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/mdbx.h b/mdbx.h index 474872c6..21c8bd03 100644 --- a/mdbx.h +++ b/mdbx.h @@ -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); /* FIXME: Complete description */ -LIBMDBX_API char *mdbx_dump_val(const MDBX_val *key, char *const buf, - const size_t bufsize); +LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf, + const size_t bufsize); /**** THE FILES **************************************************************** * At the file system level, the environment corresponds to a pair of files. */ diff --git a/src/elements/core.c b/src/elements/core.c index a2bf41a1..c886d852 100644 --- a/src/elements/core.c +++ b/src/elements/core.c @@ -2203,8 +2203,8 @@ void __cold mdbx_debug_log(int level, const char *function, int line, } /* Dump a key in ascii or hexadecimal. */ -char *mdbx_dump_val(const MDBX_val *key, char *const buf, - const size_t bufsize) { +const char *mdbx_dump_val(const MDBX_val *key, char *const buf, + const size_t bufsize) { if (!key) return ""; if (!buf || bufsize < 4) @@ -2249,7 +2249,8 @@ char *mdbx_dump_val(const MDBX_val *key, char *const buf, LY: debug stuff */ 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) ? ": overflow page" : tp[F_ISSET(node_flags(n), F_DUPDATA)] @@ -10625,7 +10626,7 @@ new_sub: size_t ecount; put_sub: 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]); if (flags & MDBX_CURRENT) { 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)) { /* put on overflow page */ /* not implemented */ - mdbx_assert_fail(env, "INDXSIZE(key) <= env->me_nodemax", __FUNCTION__, + mdbx_assert_fail(env, "INDXSIZE(key) <= env->me_nodemax", __func__, __LINE__); sz = sz - key->iov_len + sizeof(pgno_t); } diff --git a/src/elements/defs.h b/src/elements/defs.h index f70c3d77..ee0ab900 100644 --- a/src/elements/defs.h +++ b/src/elements/defs.h @@ -349,7 +349,7 @@ typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__))); #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L # define mdbx_func_ __func__ #elif (defined(__GNUC__) && __GNUC__ >= 2) || defined(__clang__) || defined(_MSC_VER) -# define mdbx_func_ __FUNCTION__ +# define mdbx_func_ __func__ #else # define mdbx_func_ "" #endif diff --git a/src/elements/internals.h b/src/elements/internals.h index 9b4b4d7f..516d05f0 100644 --- a/src/elements/internals.h +++ b/src/elements/internals.h @@ -1090,8 +1090,7 @@ MDBX_INTERNAL_FUNC void mdbx_assert_fail(const MDBX_env *env, const char *msg, #define mdbx_debug_extra(fmt, ...) \ do { \ if (mdbx_log_enabled(MDBX_LOG_EXTRA)) \ - mdbx_debug_log(MDBX_LOG_EXTRA, __FUNCTION__, __LINE__, fmt, \ - ##__VA_ARGS__); \ + mdbx_debug_log(MDBX_LOG_EXTRA, __func__, __LINE__, fmt, ##__VA_ARGS__); \ } while (0) #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, ...) \ do { \ 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__); \ } while (0) #define mdbx_debug(fmt, ...) \ do { \ 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__); \ } while (0) @@ -1123,39 +1122,38 @@ MDBX_INTERNAL_FUNC void mdbx_assert_fail(const MDBX_env *env, const char *msg, #define mdbx_verbose(fmt, ...) \ do { \ 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__); \ } while (0) #define mdbx_notice(fmt, ...) \ do { \ 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__); \ } while (0) #define mdbx_warning(fmt, ...) \ do { \ 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__); \ } while (0) #define mdbx_error(fmt, ...) \ do { \ 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__); \ } while (0) #define mdbx_fatal(fmt, ...) \ - mdbx_debug_log(MDBX_LOG_FATAL, __FUNCTION__, __LINE__, fmt "\n", \ - ##__VA_ARGS__); + mdbx_debug_log(MDBX_LOG_FATAL, __func__, __LINE__, fmt "\n", ##__VA_ARGS__); #define mdbx_ensure_msg(env, expr, msg) \ do { \ if (unlikely(!(expr))) \ - mdbx_assert_fail(env, msg, __FUNCTION__, __LINE__); \ + mdbx_assert_fail(env, msg, __func__, __LINE__); \ } while (0) #define mdbx_ensure(env, expr) mdbx_ensure_msg(env, expr, #expr) diff --git a/src/elements/osal.c b/src/elements/osal.c index 02fc4929..8feec8d8 100644 --- a/src/elements/osal.c +++ b/src/elements/osal.c @@ -241,17 +241,18 @@ MDBX_INTERNAL_FUNC __cold void mdbx_panic(const char *fmt, ...) { char *message = nullptr; const int num = mdbx_vasprintf(&message, fmt, ap); va_end(ap); - if (num < 1 || !message) - message = ""; + const char *const const_message = + (num < 1 || !message) ? "" + : message; #if defined(_WIN32) || defined(_WIN64) OutputDebugStringA("\r\nMDBX-PANIC: "); - OutputDebugStringA(message); + OutputDebugStringA(const_message); if (IsDebuggerPresent()) DebugBreak(); FatalExit(ERROR_UNHANDLED_ERROR); #else - __assert_fail(message, "mdbx", 0, "panic"); + __assert_fail(const_message, "mdbx", 0, "panic"); abort(); #endif } @@ -1325,7 +1326,7 @@ MDBX_INTERNAL_FUNC __cold void mdbx_osal_jitter(bool tiny) { #elif defined(__APPLE__) || defined(__MACH__) #include #elif defined(__linux__) || defined(__gnu_linux__) -static __cold clockid_t choice_monoclock() { +static __cold clockid_t choice_monoclock(void) { struct timespec probe; #if defined(CLOCK_BOOTTIME) if (clock_gettime(CLOCK_BOOTTIME, &probe) == 0)