mirror of
https://github.com/isar/libmdbx.git
synced 2025-10-05 12:52:20 +08:00
mdbx: fix MSVC warnings, add uint16-range-asserts.
Change-Id: Ie67a728035eeae250efbf962270b5c17c974db23
This commit is contained in:
committed by
Leo Yuriev
parent
2ed74ee78f
commit
3e6a672286
26
test/base.h
26
test/base.h
@@ -19,11 +19,22 @@
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS)
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
#pragma warning(disable : 4548) /* expression before comma has no effect; \
|
||||
expected expression with side - effect */
|
||||
#pragma warning(disable : 4530) /* C++ exception handler used, but unwind \
|
||||
semantics are not enabled. Specify /EHsc */
|
||||
#pragma warning(disable : 4577) /* 'noexcept' used with no exception handling \
|
||||
mode specified; termination on exception \
|
||||
is not guaranteed. Specify /EHsc */
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
|
||||
/* If you wish to build your application for a previous Windows platform,
|
||||
* include WinSDKVer.h and set the _WIN32_WINNT macro to the platform you
|
||||
* wish to support before including SDKDDKVer.h.
|
||||
*
|
||||
* TODO: #define _WIN32_WINNT WIN32_MUSTDIE */
|
||||
* include WinSDKVer.h and set the _WIN32_WINNT macro to the platform you
|
||||
* wish to support before including SDKDDKVer.h.
|
||||
*
|
||||
* TODO: #define _WIN32_WINNT WIN32_MUSTDIE */
|
||||
#include <SDKDDKVer.h>
|
||||
#endif /* WINDOWS */
|
||||
|
||||
@@ -74,3 +85,10 @@
|
||||
|
||||
#include "../mdbx.h"
|
||||
#include "../src/defs.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#pragma warning(disable : 4201) /* nonstandard extension used : \
|
||||
nameless struct / union */
|
||||
#pragma warning(disable : 4127) /* conditional expression is constant */
|
||||
#endif
|
||||
|
@@ -122,13 +122,17 @@ void maker::setup(const config::actor_params_pod &actor,
|
||||
unsigned thread_number) {
|
||||
key_essentials.flags =
|
||||
actor.table_flags & (MDBX_INTEGERKEY | MDBX_REVERSEKEY);
|
||||
key_essentials.minlen = actor.keylen_min;
|
||||
key_essentials.maxlen = actor.keylen_max;
|
||||
assert(actor.keylen_min < UINT8_MAX);
|
||||
key_essentials.minlen = (uint8_t)actor.keylen_min;
|
||||
assert(actor.keylen_max < UINT16_MAX);
|
||||
key_essentials.maxlen = (uint16_t)actor.keylen_max;
|
||||
|
||||
value_essentials.flags =
|
||||
actor.table_flags & (MDBX_INTEGERDUP | MDBX_REVERSEDUP);
|
||||
value_essentials.minlen = actor.datalen_min;
|
||||
value_essentials.maxlen = actor.datalen_max;
|
||||
assert(actor.datalen_min < UINT8_MAX);
|
||||
value_essentials.minlen = (uint8_t)actor.datalen_min;
|
||||
assert(actor.datalen_max < UINT16_MAX);
|
||||
value_essentials.maxlen = (uint16_t)actor.datalen_max;
|
||||
|
||||
assert(thread_number < 2);
|
||||
(void)thread_number;
|
||||
|
@@ -51,8 +51,8 @@ void setup(loglevel _level, const std::string &_prefix) {
|
||||
|
||||
void setup(const std::string &_prefix) { prefix = _prefix; }
|
||||
|
||||
const char *level2str(const loglevel level) {
|
||||
switch (level) {
|
||||
const char *level2str(const loglevel alevel) {
|
||||
switch (alevel) {
|
||||
default:
|
||||
return "invalid/unknown";
|
||||
case extra:
|
||||
|
@@ -241,20 +241,18 @@ bool testcase::wait4start() {
|
||||
}
|
||||
|
||||
void testcase::kick_progress(bool active) const {
|
||||
static chrono::time last;
|
||||
chrono::time now = chrono::now_motonic();
|
||||
|
||||
if (active) {
|
||||
static int last_point = -1;
|
||||
int point = (now.fixedpoint >> 29) & 3;
|
||||
if (point != last_point) {
|
||||
last = now;
|
||||
last.progress_timestamp = now;
|
||||
fprintf(stderr, "%c\b", "-\\|/"[last_point = point]);
|
||||
fflush(stderr);
|
||||
}
|
||||
} else if (now.fixedpoint - last.fixedpoint >
|
||||
} else if (now.fixedpoint - last.progress_timestamp.fixedpoint >
|
||||
chrono::from_seconds(2).fixedpoint) {
|
||||
last = now;
|
||||
last.progress_timestamp = now;
|
||||
fprintf(stderr, "%c\b", "@*"[now.utc & 1]);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
@@ -95,6 +95,7 @@ protected:
|
||||
|
||||
struct {
|
||||
mdbx_canary canary;
|
||||
mutable chrono::time progress_timestamp;
|
||||
} last;
|
||||
|
||||
static int oom_callback(MDBX_env *env, int pid, mdbx_tid_t tid, uint64_t txn,
|
||||
@@ -119,9 +120,9 @@ protected:
|
||||
void signal();
|
||||
bool should_continue(bool check_timeout_only = false) const;
|
||||
|
||||
void generate_pair(const keygen::serial_t serial, keygen::buffer &key,
|
||||
keygen::buffer &value, keygen::serial_t data_age = 0) {
|
||||
keyvalue_maker.pair(serial, key, value, data_age);
|
||||
void generate_pair(const keygen::serial_t serial, keygen::buffer &out_key,
|
||||
keygen::buffer &out_value, keygen::serial_t data_age = 0) {
|
||||
keyvalue_maker.pair(serial, out_key, out_value, data_age);
|
||||
}
|
||||
|
||||
void generate_pair(const keygen::serial_t serial,
|
||||
|
@@ -86,7 +86,7 @@ bool hex2data(const char *hex_begin, const char *hex_end, void *ptr,
|
||||
|
||||
uint32_t c = l + (h << 4);
|
||||
checksum.push(c);
|
||||
*data = c;
|
||||
*data = (uint8_t)c;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user