mdbx-test: fix minor Coverity warnings.

Change-Id: I53ab4ee10317b4530db727ed0b431e5de9887b74
This commit is contained in:
Leonid Yuriev 2020-05-01 00:22:51 +03:00
parent b943466727
commit 07174cbfdf
2 changed files with 11 additions and 10 deletions

View File

@ -517,9 +517,9 @@ std::string osal_tempdir(void) {
tempdir = getenv("TEMPDIR"); tempdir = getenv("TEMPDIR");
if (!tempdir) if (!tempdir)
tempdir = getenv("TEMP"); tempdir = getenv("TEMP");
if (tempdir) { if (tempdir && *tempdir) {
std::string dir(tempdir); std::string dir(tempdir);
if (!dir.empty() && dir.at(dir.length() - 1) != '/') if (dir.back() != '/')
dir.append("/"); dir.append("/");
return dir; return dir;
} }

View File

@ -104,7 +104,9 @@ protected:
using data_view = std::string; using data_view = std::string;
#endif #endif
static inline data_view S(const MDBX_val &v) { static inline data_view S(const MDBX_val &v) {
return data_view(static_cast<const char *>(v.iov_base), v.iov_len); return (v.iov_base && v.iov_len)
? data_view(static_cast<const char *>(v.iov_base), v.iov_len)
: data_view();
} }
static inline data_view S(const keygen::buffer &b) { return S(b->value); } static inline data_view S(const keygen::buffer &b) { return S(b->value); }
@ -136,13 +138,13 @@ protected:
const actor_config &config; const actor_config &config;
const mdbx_pid_t pid; const mdbx_pid_t pid;
MDBX_dbi dbi; MDBX_dbi dbi{0};
scoped_db_guard db_guard; scoped_db_guard db_guard;
scoped_txn_guard txn_guard; scoped_txn_guard txn_guard;
scoped_cursor_guard cursor_guard; scoped_cursor_guard cursor_guard;
bool signalled; bool signalled{false};
size_t nops_completed; size_t nops_completed{0};
chrono::time start_timestamp; chrono::time start_timestamp;
keygen::buffer key; keygen::buffer key;
keygen::buffer data; keygen::buffer data;
@ -152,7 +154,7 @@ protected:
mdbx_canary canary; mdbx_canary canary;
} last; } last;
SET speculum; SET speculum{ItemCompare(this)};
bool speculum_verify(); bool speculum_verify();
int insert(const keygen::buffer &akey, const keygen::buffer &adata, int insert(const keygen::buffer &akey, const keygen::buffer &adata,
unsigned flags); unsigned flags);
@ -211,8 +213,7 @@ protected:
public: public:
testcase(const actor_config &config, const mdbx_pid_t pid) testcase(const actor_config &config, const mdbx_pid_t pid)
: config(config), pid(pid), signalled(false), nops_completed(0), : config(config), pid(pid) {
speculum(ItemCompare(this)) {
start_timestamp.reset(); start_timestamp.reset();
memset(&last, 0, sizeof(last)); memset(&last, 0, sizeof(last));
} }
@ -290,7 +291,7 @@ class testcase_nested : public testcase {
using inherited = testcase; using inherited = testcase;
using FIFO = std::deque<std::pair<uint64_t, unsigned>>; using FIFO = std::deque<std::pair<uint64_t, unsigned>>;
uint64_t serial; uint64_t serial{0};
FIFO fifo; FIFO fifo;
std::stack<std::tuple<scoped_txn_guard, uint64_t, FIFO, SET>> stack; std::stack<std::tuple<scoped_txn_guard, uint64_t, FIFO, SET>> stack;