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

View File

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