mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
lmdb: fix clang warnings.
Change-Id: I6586b44c21872e7a1e128d0053837b73ed4448ec
This commit is contained in:
parent
4554b8f62c
commit
1b78961cf6
29
mdb_chk.c
29
mdb_chk.c
@ -221,8 +221,10 @@ static int pgvisitor(size_t pgno, unsigned pgnumber, void* ctx, const char* dbi,
|
|||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
if (verbose > 2 && (!only_subdb || strcmp(only_subdb, dbi) == 0)) {
|
if (verbose > 2 && (!only_subdb || strcmp(only_subdb, dbi) == 0)) {
|
||||||
print((pgnumber == 1) ? " %s-page %zu" : " %s-span %zu[%u]",
|
if (pgnumber == 1)
|
||||||
type, pgno, pgnumber);
|
print(" %s-page %zu", type, pgno);
|
||||||
|
else
|
||||||
|
print(" %s-span %zu[%u]", type, pgno, pgnumber);
|
||||||
print(" of %s: header %i, payload %i, unused %i\n",
|
print(" of %s: header %i, payload %i, unused %i\n",
|
||||||
dbi, header_bytes, payload_bytes, unused_bytes);
|
dbi, header_bytes, payload_bytes, unused_bytes);
|
||||||
}
|
}
|
||||||
@ -334,7 +336,10 @@ static int handle_freedb(size_t record_number, MDB_val *key, MDB_val* data) {
|
|||||||
while (j >= 0) {
|
while (j >= 0) {
|
||||||
pg = iptr[j];
|
pg = iptr[j];
|
||||||
for (span = 1; --j >= 0 && iptr[j] == pg + span; span++) ;
|
for (span = 1; --j >= 0 && iptr[j] == pg + span; span++) ;
|
||||||
print((span > 1) ? " %9zu[%zd]\n" : " %9zu\n", pg, span);
|
if (span > 1)
|
||||||
|
print(" %9zu[%zd]\n", pg, span);
|
||||||
|
else
|
||||||
|
print(" %9zu\n", pg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -710,19 +715,21 @@ int main(int argc, char *argv[])
|
|||||||
meta_synctype(info.me_meta1_sign), info.me_meta1_txnid,
|
meta_synctype(info.me_meta1_sign), info.me_meta1_txnid,
|
||||||
meta_lt(info.me_meta1_txnid, info.me_meta1_sign,
|
meta_lt(info.me_meta1_txnid, info.me_meta1_sign,
|
||||||
info.me_meta2_txnid, info.me_meta2_sign) ? "tail" : "head");
|
info.me_meta2_txnid, info.me_meta2_sign) ? "tail" : "head");
|
||||||
print(info.me_meta1_txnid > info.me_last_txnid
|
if (info.me_meta1_txnid > info.me_last_txnid)
|
||||||
? ", rolled-back %zu (%zu >>> %zu)\n" : "\n",
|
print(", rolled-back %zu (%zu >>> %zu)\n",
|
||||||
info.me_meta1_txnid - info.me_last_txnid,
|
info.me_meta1_txnid - info.me_last_txnid,
|
||||||
info.me_meta1_txnid, info.me_last_txnid);
|
info.me_meta1_txnid, info.me_last_txnid);
|
||||||
|
print("\n");
|
||||||
|
|
||||||
print(" - meta-2: %s %zu, %s",
|
print(" - meta-2: %s %zu, %s",
|
||||||
meta_synctype(info.me_meta2_sign), info.me_meta2_txnid,
|
meta_synctype(info.me_meta2_sign), info.me_meta2_txnid,
|
||||||
meta_lt(info.me_meta2_txnid, info.me_meta2_sign,
|
meta_lt(info.me_meta2_txnid, info.me_meta2_sign,
|
||||||
info.me_meta1_txnid, info.me_meta1_sign) ? "tail" : "head");
|
info.me_meta1_txnid, info.me_meta1_sign) ? "tail" : "head");
|
||||||
print(info.me_meta2_txnid > info.me_last_txnid
|
if (info.me_meta2_txnid > info.me_last_txnid)
|
||||||
? ", rolled-back %zu (%zu >>> %zu)\n" : "\n",
|
print(", rolled-back %zu (%zu >>> %zu)\n",
|
||||||
info.me_meta2_txnid - info.me_last_txnid,
|
info.me_meta2_txnid - info.me_last_txnid,
|
||||||
info.me_meta2_txnid, info.me_last_txnid);
|
info.me_meta2_txnid, info.me_last_txnid);
|
||||||
|
print("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exclusive > 1) {
|
if (exclusive > 1) {
|
||||||
|
50
mdb_stat.c
50
mdb_stat.c
@ -17,22 +17,16 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "lmdb.h"
|
#include "lmdb.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define Z "I"
|
|
||||||
#else
|
|
||||||
#define Z "z"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void prstat(MDB_stat *ms)
|
static void prstat(MDB_stat *ms)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
printf(" Page size: %u\n", ms->ms_psize);
|
printf(" Page size: %u\n", ms->ms_psize);
|
||||||
#endif
|
#endif
|
||||||
printf(" Tree depth: %u\n", ms->ms_depth);
|
printf(" Tree depth: %u\n", ms->ms_depth);
|
||||||
printf(" Branch pages: %"Z"u\n", ms->ms_branch_pages);
|
printf(" Branch pages: %zu\n", ms->ms_branch_pages);
|
||||||
printf(" Leaf pages: %"Z"u\n", ms->ms_leaf_pages);
|
printf(" Leaf pages: %zu\n", ms->ms_leaf_pages);
|
||||||
printf(" Overflow pages: %"Z"u\n", ms->ms_overflow_pages);
|
printf(" Overflow pages: %zu\n", ms->ms_overflow_pages);
|
||||||
printf(" Entries: %"Z"u\n", ms->ms_entries);
|
printf(" Entries: %zu\n", ms->ms_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(char *prog)
|
static void usage(char *prog)
|
||||||
@ -125,12 +119,12 @@ int main(int argc, char *argv[])
|
|||||||
(void)mdb_env_info(env, &mei);
|
(void)mdb_env_info(env, &mei);
|
||||||
printf("Environment Info\n");
|
printf("Environment Info\n");
|
||||||
printf(" Map address: %p\n", mei.me_mapaddr);
|
printf(" Map address: %p\n", mei.me_mapaddr);
|
||||||
printf(" Map size: %"Z"u\n", mei.me_mapsize);
|
printf(" Map size: %zu\n", mei.me_mapsize);
|
||||||
printf(" Page size: %u\n", mst.ms_psize);
|
printf(" Page size: %u\n", mst.ms_psize);
|
||||||
printf(" Max pages: %"Z"u\n", mei.me_mapsize / mst.ms_psize);
|
printf(" Max pages: %zu\n", mei.me_mapsize / mst.ms_psize);
|
||||||
printf(" Number of pages used: %"Z"u\n", mei.me_last_pgno+1);
|
printf(" Number of pages used: %zu\n", mei.me_last_pgno+1);
|
||||||
printf(" Last transaction ID: %"Z"u\n", mei.me_last_txnid);
|
printf(" Last transaction ID: %zu\n", mei.me_last_txnid);
|
||||||
printf(" Tail transaction ID: %"Z"u (%"Z"i)\n",
|
printf(" Tail transaction ID: %zu (%zi)\n",
|
||||||
mei.me_tail_txnid, mei.me_tail_txnid - mei.me_last_txnid);
|
mei.me_tail_txnid, mei.me_tail_txnid - mei.me_last_txnid);
|
||||||
printf(" Max readers: %u\n", mei.me_maxreaders);
|
printf(" Max readers: %u\n", mei.me_maxreaders);
|
||||||
printf(" Number of readers used: %u\n", mei.me_numreaders);
|
printf(" Number of readers used: %u\n", mei.me_numreaders);
|
||||||
@ -196,14 +190,16 @@ int main(int argc, char *argv[])
|
|||||||
pg += span;
|
pg += span;
|
||||||
for (; i >= span && iptr[i-span] == pg; span++, pg++) ;
|
for (; i >= span && iptr[i-span] == pg; span++, pg++) ;
|
||||||
}
|
}
|
||||||
printf(" Transaction %"Z"u, %"Z"d pages, maxspan %"Z"d%s\n",
|
printf(" Transaction %zu, %zd pages, maxspan %zd%s\n",
|
||||||
*(size_t *)key.mv_data, j, span, bad);
|
*(size_t *)key.mv_data, j, span, bad);
|
||||||
if (freinfo > 2) {
|
if (freinfo > 2) {
|
||||||
for (--j; j >= 0; ) {
|
for (--j; j >= 0; ) {
|
||||||
pg = iptr[j];
|
pg = iptr[j];
|
||||||
for (span=1; --j >= 0 && iptr[j] == pg+span; span++) ;
|
for (span=1; --j >= 0 && iptr[j] == pg+span; span++) ;
|
||||||
printf(span>1 ? " %9"Z"u[%"Z"d]\n" : " %9"Z"u\n",
|
if (span>1)
|
||||||
pg, span);
|
printf(" %9zu[%zd]\n", pg, span);
|
||||||
|
else
|
||||||
|
printf(" %9zu\n", pg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,30 +209,30 @@ int main(int argc, char *argv[])
|
|||||||
size_t value = mei.me_mapsize / mst.ms_psize;
|
size_t value = mei.me_mapsize / mst.ms_psize;
|
||||||
double percent = value / 100.0;
|
double percent = value / 100.0;
|
||||||
printf("Page Allocation Info\n");
|
printf("Page Allocation Info\n");
|
||||||
printf(" Max pages: %9"Z"u 100%%\n", value);
|
printf(" Max pages: %9zu 100%%\n", value);
|
||||||
|
|
||||||
value = mei.me_last_pgno+1;
|
value = mei.me_last_pgno+1;
|
||||||
printf(" Number of pages used: %"Z"u %.1f%%\n", value, value / percent);
|
printf(" Number of pages used: %zu %.1f%%\n", value, value / percent);
|
||||||
|
|
||||||
value = mei.me_mapsize / mst.ms_psize - (mei.me_last_pgno+1);
|
value = mei.me_mapsize / mst.ms_psize - (mei.me_last_pgno+1);
|
||||||
printf(" Remained: %"Z"u %.1f%%\n", value, value / percent);
|
printf(" Remained: %zu %.1f%%\n", value, value / percent);
|
||||||
|
|
||||||
value = mei.me_last_pgno+1 - pages;
|
value = mei.me_last_pgno+1 - pages;
|
||||||
printf(" Used now: %"Z"u %.1f%%\n", value, value / percent);
|
printf(" Used now: %zu %.1f%%\n", value, value / percent);
|
||||||
|
|
||||||
value = pages;
|
value = pages;
|
||||||
printf(" Free pages: %"Z"u %.1f%%\n", value, value / percent);
|
printf(" Free pages: %zu %.1f%%\n", value, value / percent);
|
||||||
|
|
||||||
value = pages - reclaimable;
|
value = pages - reclaimable;
|
||||||
printf(" Reading: %"Z"u %.1f%%\n", value, value / percent);
|
printf(" Reading: %zu %.1f%%\n", value, value / percent);
|
||||||
|
|
||||||
value = reclaimable;
|
value = reclaimable;
|
||||||
printf(" Reclaimable: %"Z"u %.1f%%\n", value, value / percent);
|
printf(" Reclaimable: %zu %.1f%%\n", value, value / percent);
|
||||||
|
|
||||||
value = mei.me_mapsize / mst.ms_psize - (mei.me_last_pgno+1) + reclaimable;
|
value = mei.me_mapsize / mst.ms_psize - (mei.me_last_pgno+1) + reclaimable;
|
||||||
printf(" Available: %"Z"u %.1f%%\n", value, value / percent);
|
printf(" Available: %zu %.1f%%\n", value, value / percent);
|
||||||
} else
|
} else
|
||||||
printf(" Free pages: %"Z"u\n", pages);
|
printf(" Free pages: %zu\n", pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = mdb_open(txn, subname, 0, &dbi);
|
rc = mdb_open(txn, subname, 0, &dbi);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user