From f96bb5ef4ae1321dda9733415d16f967c8503f0c Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Fri, 21 Jul 2017 22:37:49 +0300 Subject: [PATCH 1/2] mdbx-tools: fix coverity issue (minor). Change-Id: I8031a59336134a355ea31d6f41b241dbc176f577 --- src/tools/mdbx_stat.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/tools/mdbx_stat.c b/src/tools/mdbx_stat.c index 9b65d992..a8567b2b 100644 --- a/src/tools/mdbx_stat.c +++ b/src/tools/mdbx_stat.c @@ -234,7 +234,8 @@ int main(int argc, char *argv[]) { goto txn_abort; } prstat(&mst); - while ((rc = mdbx_cursor_get(cursor, &key, &data, MDBX_NEXT)) == 0) { + while ((rc = mdbx_cursor_get(cursor, &key, &data, MDBX_NEXT)) == + MDBX_SUCCESS) { if (user_break) { rc = MDBX_EINTR; break; @@ -274,6 +275,20 @@ int main(int argc, char *argv[]) { } } mdbx_cursor_close(cursor); + + switch (rc) { + case MDBX_SUCCESS: + case MDBX_NOTFOUND: + break; + case MDBX_EINTR: + fprintf(stderr, "Interrupted by signal/user\n"); + goto txn_abort; + default: + fprintf(stderr, "mdbx_cursor_get failed, error %d %s\n", rc, + mdbx_strerror(rc)); + goto txn_abort; + } + if (envinfo) { uint64_t value = mei.mi_mapsize / mst.ms_psize; double percent = value / 100.0; From 425254aba513b48766aedf1e5edeb071ccff34a9 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Fri, 21 Jul 2017 22:45:42 +0300 Subject: [PATCH 2/2] mdbx-tools: hush MSVC's internal warnings. Change-Id: I2b2bdb149149aa8bafff0bb7df205547f645fe10 --- libmdbx.files | 2 ++ src/tools/wingetopt.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libmdbx.files b/libmdbx.files index b6b1d7a2..153bfe32 100644 --- a/libmdbx.files +++ b/libmdbx.files @@ -20,6 +20,8 @@ src/tools/mdbx_load.1 src/tools/mdbx_load.c src/tools/mdbx_stat.1 src/tools/mdbx_stat.c +src/tools/wingetopt.c +src/tools/wingetopt.h src/version.c test/actor.cc test/base.h diff --git a/src/tools/wingetopt.c b/src/tools/wingetopt.c index 8059e5d9..1dd0d069 100644 --- a/src/tools/wingetopt.c +++ b/src/tools/wingetopt.c @@ -6,10 +6,32 @@ * Code given out at the 1985 UNIFORUM conference in Dallas. */ +/*----------------------------------------------------------------------------*/ +/* Microsoft compiler generates a lot of warning for self includes... */ + +#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 */ +#if !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif +#endif /* _MSC_VER (warnings) */ + #include "wingetopt.h" #include #include +#ifdef _MSC_VER +#pragma warning(pop) +#endif +/*----------------------------------------------------------------------------*/ + #ifndef NULL #define NULL 0 #endif