mdbx: fix MSVC warnings.

Change-Id: Ida49e653510358d7c81fe5da73a0131dcb6268f6
This commit is contained in:
Leo Yuriev 2017-07-27 17:05:38 +03:00
parent 684847db39
commit c6fc062cfd
3 changed files with 26 additions and 24 deletions

View File

@ -1877,9 +1877,9 @@ static int mdbx_page_alloc(MDBX_cursor *mc, unsigned num, MDBX_page **mp,
}
if (tail != txn->mt_next_pgno) {
#if MDBX_PNL_ASCENDING
repg_len = higest + 1 - begin;
repg_len = (unsigned)(higest + 1 - begin);
#else
repg_len -= higest - begin;
repg_len -= (unsigned)(higest - begin);
for (pgno_t *move = begin; higest < end; ++move, ++higest)
*move = *higest;
#endif /* MDBX_PNL sort-order */
@ -3083,9 +3083,9 @@ again_on_freelist_change:
}
if (tail != txn->mt_next_pgno) {
#if MDBX_PNL_ASCENDING
env->me_reclaimed_pglist[0] = higest + 1 - begin;
env->me_reclaimed_pglist[0] = (unsigned)(higest + 1 - begin);
#else
env->me_reclaimed_pglist[0] -= higest - begin;
env->me_reclaimed_pglist[0] -= (unsigned)(higest - begin);
for (pgno_t *move = begin; higest < end; ++move, ++higest)
*move = *higest;
#endif /* MDBX_PNL sort-order */

View File

@ -340,32 +340,32 @@ static int handle_freedb(const uint64_t record_number, const MDBX_val *key,
problem_add("entry", record_number, "wrong idl size", "%" PRIuPTR "",
data->iov_len);
else {
const intptr_t number = *iptr++;
const pgno_t number = *iptr++;
if (number >= MDBX_PNL_UM_MAX)
problem_add("entry", record_number, "wrong idl length", "%" PRIiPTR "",
number);
else if ((number + 1) * sizeof(pgno_t) != data->iov_len)
problem_add("entry", record_number, "mismatch idl length",
"%" PRIiPTR " != %" PRIuPTR "", (number + 1) * sizeof(pgno_t),
data->iov_len);
"%" PRIuSIZE " != %" PRIuSIZE "",
(number + 1) * sizeof(pgno_t), data->iov_len);
else {
freedb_pages += number;
if (envinfo.mi_latter_reader_txnid > txnid)
reclaimable_pages += number;
pgno_t prev =
MDBX_PNL_ASCENDING ? NUM_METAS - 1 : envinfo.mi_last_pgno + 1;
intptr_t span = 1;
for (intptr_t i = 0; i < number; ++i) {
MDBX_PNL_ASCENDING ? NUM_METAS - 1 : (pgno_t)envinfo.mi_last_pgno + 1;
pgno_t span = 1;
for (unsigned i = 0; i < number; ++i) {
const pgno_t pg = iptr[i];
if (pg < NUM_METAS || pg > envinfo.mi_last_pgno)
problem_add("entry", record_number, "wrong idl entry",
"%u < %" PRIiPTR " < %" PRIiPTR "", NUM_METAS, pg,
"%u < %" PRIaPGNO " < %" PRIu64 "", NUM_METAS, pg,
envinfo.mi_last_pgno);
else if (MDBX_PNL_DISORDERED(prev, pg)) {
bad = " [bad sequence]";
problem_add("entry", record_number, "bad sequence",
"%" PRIiPTR " <> %" PRIiPTR "", prev, pg);
"%" PRIaPGNO " <> %" PRIaPGNO "", prev, pg);
}
prev = pg;
while (i + span < number &&
@ -374,10 +374,11 @@ static int handle_freedb(const uint64_t record_number, const MDBX_val *key,
++span;
}
if (verbose > 2 && !only_subdb) {
print(" transaction %" PRIaTXN ", %u pages, maxspan %i%s\n", txnid,
number, span, bad);
print(" transaction %" PRIaTXN ", %" PRIaPGNO
" pages, maxspan %" PRIaPGNO "%s\n",
txnid, number, span, bad);
if (verbose > 3) {
for (intptr_t i = 0; i < number; i += span) {
for (unsigned i = 0; i < number; i += span) {
const pgno_t pg = iptr[i];
for (span = 1;
i + span < number &&
@ -386,7 +387,7 @@ static int handle_freedb(const uint64_t record_number, const MDBX_val *key,
++span)
;
if (span > 1) {
print(" %9" PRIaPGNO "[%" PRIiPTR "]\n", pg, span);
print(" %9" PRIaPGNO "[%" PRIaPGNO "]\n", pg, span);
} else
print(" %9" PRIaPGNO "\n", pg);
}

View File

@ -234,7 +234,7 @@ int main(int argc, char *argv[]) {
break;
}
iptr = data.iov_base;
const intptr_t number = *iptr++;
const pgno_t number = *iptr++;
pages += number;
if (envinfo && mei.mi_latter_reader_txnid > *(size_t *)key.iov_base)
@ -242,9 +242,10 @@ int main(int argc, char *argv[]) {
if (freinfo > 1) {
char *bad = "";
pgno_t prev = MDBX_PNL_ASCENDING ? NUM_METAS - 1 : mei.mi_last_pgno + 1;
intptr_t i, span = 1;
for (i = 0; i < number; ++i) {
pgno_t prev =
MDBX_PNL_ASCENDING ? NUM_METAS - 1 : (pgno_t)mei.mi_last_pgno + 1;
pgno_t span = 1;
for (unsigned i = 0; i < number; ++i) {
pgno_t pg = iptr[i];
if (MDBX_PNL_DISORDERED(prev, pg))
bad = " [bad sequence]";
@ -254,11 +255,11 @@ int main(int argc, char *argv[]) {
: pgno_sub(pg, span)))
++span;
}
printf(" Transaction %" PRIaTXN ", %" PRIiPTR
" pages, maxspan %" PRIiPTR "%s\n",
printf(" Transaction %" PRIaTXN ", %" PRIaPGNO
" pages, maxspan %" PRIaPGNO "%s\n",
*(txnid_t *)key.iov_base, number, span, bad);
if (freinfo > 2) {
for (intptr_t i = 0; i < number; i += span) {
for (unsigned i = 0; i < number; i += span) {
const pgno_t pg = iptr[i];
for (span = 1;
i + span < number &&
@ -267,7 +268,7 @@ int main(int argc, char *argv[]) {
++span)
;
if (span > 1)
printf(" %9" PRIaPGNO "[%" PRIiPTR "]\n", pg, span);
printf(" %9" PRIaPGNO "[%" PRIaPGNO "]\n", pg, span);
else
printf(" %9" PRIaPGNO "\n", pg);
}