Commit 7bd618ee authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #5206 merge work making our code c99 and c++11 compatible, to mainline

git-svn-id: file:///svn/toku/tokudb@45632 c7de825b-a66e-492c-adef-691d508d4ae1
parent 426521a6
......@@ -8,6 +8,6 @@ set(CTEST_PROJECT_NAME "tokudb")
set(CTEST_NIGHTLY_START_TIME "23:59:00 EDT")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "192.168.1.114")
set(CTEST_DROP_SITE "localhost:8080")
set(CTEST_DROP_LOCATION "/CDash/submit.php?project=tokudb")
set(CTEST_DROP_SITE_CDASH TRUE)
......@@ -18,15 +18,15 @@
#define FIELD_LIMIT 100
struct fieldinfo {
char *decl_format_string;
char *name;
const char *decl_format_string;
const char *name;
size_t offset;
} fields[FIELD_LIMIT];
static int field_counter=0;
static int compare_fields (const void *av, const void *bv) {
const struct fieldinfo *a = av;
const struct fieldinfo *b = bv;
const struct fieldinfo *a = (const struct fieldinfo *) av;
const struct fieldinfo *b = (const struct fieldinfo *) bv;
if (a->offset< b->offset) return -1;
if (a->offset==b->offset) return 0;
return +1;
......@@ -282,7 +282,7 @@ static void print_db_env_struct (void) {
STRUCT_SETUP(DB_ENV, api1_internal, "void *%s"); /* Used for C++ hacking. */
STRUCT_SETUP(DB_ENV, app_private, "void *%s");
STRUCT_SETUP(DB_ENV, close, "int (*%s) (DB_ENV *, u_int32_t)");
STRUCT_SETUP(DB_ENV, err, "void (*%s) (const DB_ENV *, int, const char *, ...)");
STRUCT_SETUP(DB_ENV, err, "void (*%s) (const DB_ENV *, int, const char *, ...) __attribute__ (( format (printf, 3, 4) ))");
#if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3
STRUCT_SETUP(DB_ENV, get_cachesize, "int (*%s) (DB_ENV *, u_int32_t *, u_int32_t *, int *)");
STRUCT_SETUP(DB_ENV, get_flags, "int (*%s) (DB_ENV *, u_int32_t *)");
......@@ -626,12 +626,12 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) {
printf("} toku_engine_status_display_type; \n");
printf("typedef struct __toku_engine_status_row {\n");
printf(" char * keyname; // info schema key, should not change across revisions without good reason \n");
printf(" char * legend; // the text that will appear at user interface \n");
printf(" const char * keyname; // info schema key, should not change across revisions without good reason \n");
printf(" const char * legend; // the text that will appear at user interface \n");
printf(" toku_engine_status_display_type type; // how to interpret the value \n");
printf(" union { \n");
printf(" uint64_t num; \n");
printf(" char * str; \n");
printf(" const char * str; \n");
printf(" } value; \n");
printf("} * TOKU_ENGINE_STATUS_ROW, TOKU_ENGINE_STATUS_ROW_S; \n");
......@@ -684,11 +684,11 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) {
printf("int db_env_create(DB_ENV **, u_int32_t) %s;\n", VISIBLE);
printf("int db_create(DB **, DB_ENV *, u_int32_t) %s;\n", VISIBLE);
printf("char *db_strerror(int) %s;\n", VISIBLE);
printf("const char *db_strerror(int) %s;\n", VISIBLE);
printf("const char *db_version(int*,int *,int *) %s;\n", VISIBLE);
printf("int log_compare (const DB_LSN*, const DB_LSN *) %s;\n", VISIBLE);
printf("int db_env_set_func_fsync (int (*)(int)) %s;\n", VISIBLE);
printf("int toku_set_trace_file (char *fname) %s;\n", VISIBLE);
printf("int toku_set_trace_file (const char *fname) %s;\n", VISIBLE);
printf("int toku_close_trace_file (void) %s;\n", VISIBLE);
printf("int db_env_set_func_free (void (*)(void*)) %s;\n", VISIBLE);
printf("int db_env_set_func_malloc (void *(*)(size_t)) %s;\n", VISIBLE);
......
......@@ -53,7 +53,7 @@ set_cflags_if_supported(
)
## set extra debugging flags and preprocessor definitions
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g3 -ggdb -O0")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g3 -ggdb -O1")
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG FORTIFY_SOURCE=2)
## set extra release flags, we overwrite this because the default passes -DNDEBUG and we don't want that
......@@ -101,6 +101,8 @@ if (CMAKE_C_COMPILER_ID MATCHES Intel)
else()
## set gcc warnings
set(CMAKE_C_FLAGS "-Wextra ${CMAKE_C_FLAGS}")
## -Wc++-compat doesn't work with cmake's variable names so we do it individually here
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wc++-compat")
set(WARN_CFLAGS
-Wbad-function-cast
-Wno-missing-noreturn
......@@ -110,6 +112,18 @@ else()
-Wpointer-arith
-Wmissing-format-attribute
)
if (WARN_ABOUT_PACKED)
list(APPEND WARN_CFLAGS -Wpacked -Wno-error=packed)
endif ()
## other flags to try:
## -Wunsafe-loop-optimizations
## -Wpointer-arith
## -Wc++-compat
## -Wc++11-compat
## -Wwrite-strings
## -Wzero-as-null-pointer-constant
## -Wlogical-op
## -Wvector-optimization-performance
if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
message(WARNING "Disabling -Wcast-align and -Wshadow on osx. TODO: fix casting and shadowed declarations and re-enable them.")
elseif (CMAKE_C_COMPILER_ID STREQUAL Clang)
......
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE DONT_DEPRECATE_ERRNO)
set(both_bins
db-benchmark-test
......
......@@ -131,7 +131,7 @@ static void do_prelock(DB* db, DB_TXN* txn) {
#define STRINGIFY2(s) #s
#define STRINGIFY(s) STRINGIFY2(s)
const char *dbdir = "./bench." STRINGIFY(DIRSUF); /* DIRSUF is passed in as a -D argument to the compiler. */
char *dbfilename = "bench.db";
const char *dbfilename = "bench.db";
char *dbname;
DB_ENV *dbenv;
......@@ -406,8 +406,8 @@ static void fill_array (unsigned char *data, int size) {
static void insert (long long v) {
int r;
unsigned char *kc = toku_malloc(keysize);
unsigned char *vc = toku_malloc(valsize);
unsigned char *XMALLOC_N(keysize, kc);
unsigned char *XMALLOC_N(valsize, vc);
DBT kt, vt;
fill_array(kc, keysize);
long_long_to_array(kc, keysize, v); // Fill in the array first, then write the long long in.
......@@ -546,9 +546,9 @@ static int print_usage (const char *argv0) {
fprintf(stderr, " --1514 do a point query for something not there at end. See #1514. (Requires --norandom)\n");
fprintf(stderr, " --append append to an existing file\n");
fprintf(stderr, " --userandom use random()\n");
fprintf(stderr, " --checkpoint-period %"PRIu32" checkpoint period\n", checkpoint_period);
fprintf(stderr, " --cleaner-period %"PRIu32" cleaner period\n", cleaner_period);
fprintf(stderr, " --cleaner-iterations %"PRIu32" cleaner iterations\n", cleaner_iterations);
fprintf(stderr, " --checkpoint-period %" PRIu32 " checkpoint period\n", checkpoint_period);
fprintf(stderr, " --cleaner-period %" PRIu32 " cleaner period\n", cleaner_period);
fprintf(stderr, " --cleaner-iterations %" PRIu32 " cleaner iterations\n", cleaner_iterations);
fprintf(stderr, " --numdbs N Insert same items into N dbs (1 to %d)\n", MAX_DBS);
fprintf(stderr, " --insertmultiple Use DB_ENV->put_multiple api. Requires transactions.\n");
fprintf(stderr, " --redzone N redzone in percent\n");
......
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#include <db.h>
#include "tokudb_common_funcs.h"
#include <assert.h>
static int verbose = 0;
static int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK;
......@@ -13,8 +13,8 @@ static int env_open_flags_nox = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL;
int test_main(int argc, char * const argv[]) {
int r;
char *envdir = "bench.tokudb";
char *dbfilename = "bench.db";
const char *envdir = "bench.tokudb";
const char *dbfilename = "bench.db";
bool do_txns = false;
for (int i = 1; i < argc; i++) {
......@@ -50,7 +50,7 @@ int test_main(int argc, char * const argv[]) {
if (verbose) {
DB_BTREE_STAT64 s;
r = db->stat64(db, NULL, &s); assert(r == 0);
printf("nkeys=%" PRIu64" dsize=%" PRIu64 "\n", s.bt_nkeys, s.bt_dsize);
printf("nkeys=%" PRIu64 " dsize=%" PRIu64 "\n", s.bt_nkeys, s.bt_dsize);
}
r = db->verify_with_progress(db, NULL, NULL, verbose > 0, false);
......
......@@ -73,7 +73,7 @@ static int inserter(struct keygen *keygen, DB_ENV *env, DB *db) {
if (r != 0)
break;
if (verbose) printf("%d: %"PRIu64"\n", (int) pthread_self(), k);
if (verbose) printf("%d: %" PRIu64 "\n", (int) pthread_self(), k);
DB_TXN *txn;
r = env->txn_begin(env, NULL, &txn, 0);
......
......@@ -19,7 +19,7 @@ static DB *db = NULL;
static const char *dbdir = "./bench." STRINGIFY(DIRSUF); /* DIRSUF is passed in as a -D argument to the compiler. */
static int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK|DB_RECOVER|DB_THREAD;
// static int env_open_flags_nox = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL;
static char *dbfilename = "bench.db";
static const char *dbfilename = "bench.db";
static u_int64_t cachesize = 127*1024*1024;
static int nqueries = 1000000;
static int nthreads = 1;
......@@ -130,7 +130,7 @@ static void warmup(void) {
memset(&key, 0, sizeof key);
memset(&val, 0, sizeof val);
r = c->c_get(c, &key, &val, DB_LAST); assert_zero(r);
array_to_long_long(&maxkey, key.data, key.size);
array_to_long_long(&maxkey, (unsigned char*)key.data, key.size);
r = c->c_close(c); assert_zero(r);
r = txn->commit(txn, 0); assert_zero(r);
double tdiff = gettime() - tstart;
......
......@@ -63,7 +63,7 @@ DB_TXN *tid=0;
static int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK;
char *dbfilename = "bench.db";
const char *dbfilename = "bench.db";
static void scanrace_setup (void) {
int r;
......@@ -107,7 +107,7 @@ struct extra_count {
static int
counttotalbytes (DBT const *key, DBT const *data, void *extrav) {
struct extra_count *e=extrav;
struct extra_count *e = cast_to_typeof(e) extrav;
e->totalbytes += key->size + data->size;
e->rowcounter++;
return 0;
......
......@@ -68,7 +68,7 @@ static DB_TXN *tid = NULL;
static const char *dbdir = "./bench." STRINGIFY(DIRSUF); /* DIRSUF is passed in as a -D argument to the compiler. */
static int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK;
static int env_open_flags_nox = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL;
static char *dbfilename = "bench.db";
static const char *dbfilename = "bench.db";
static double gettime (void) {
struct timeval tv;
......@@ -170,8 +170,8 @@ static inline uint64_t mysql_get_bigint(unsigned char *d) {
static int mysql_key_compare(DB* file __attribute__((unused)),
const DBT *adbt, const DBT *bdbt) {
unsigned char *adata = adbt->data;
unsigned char *bdata = bdbt->data;
unsigned char *adata = cast_to_typeof(adata) adbt->data;
unsigned char *bdata = cast_to_typeof(bdata) bdbt->data;
uint64_t a, b;
assert(adbt->size == 9 && bdbt->size == 9);
assert(adata[0] == 0 && bdata[0] == 0);
......@@ -286,14 +286,14 @@ struct extra_count {
};
static int counttotalbytes (DBT const *key, DBT const *data, void *extrav) {
struct extra_count *e=extrav;
struct extra_count *e = cast_to_typeof(e) extrav;
e->totalbytes += key->size + data->size;
e->rowcounter++;
if (do_mysql && 0) {
static uint64_t expect_key = 0;
uint64_t k = mysql_get_bigint((unsigned char*)key->data+1);
if (k != expect_key)
printf("%s:%d %"PRIu64" %"PRIu64"\n", __FUNCTION__, __LINE__, k, expect_key);
printf("%s:%d %" PRIu64 " %" PRIu64 "\n", __FUNCTION__, __LINE__, k, expect_key);
expect_key = k + 1;
}
return bulk_fetch ? TOKUDB_CURSOR_CONTINUE : 0;
......@@ -358,7 +358,7 @@ static void scanscan_range (void) {
r = dbc->c_get(dbc, &key, &val, DB_SET_RANGE+lock_flag);
if (r != 0) {
assert(r == DB_NOTFOUND);
//printf("%s:%d %"PRIu64"\n", __FUNCTION__, __LINE__, k);
//printf("%s:%d %" PRIu64 "\n", __FUNCTION__, __LINE__, k);
goto makekey;
}
......@@ -378,7 +378,7 @@ static void scanscan_range (void) {
assert(r==0);
texperiments[counter] = gettime() - tstart;
printf("%"PRIu64" %f\n", k, texperiments[counter]); fflush(stdout);
printf("%" PRIu64 " %f\n", k, texperiments[counter]); fflush(stdout);
}
// print the times
......@@ -403,7 +403,7 @@ struct extra_verify {
static int
checkbytes (DBT const *key, DBT const *data, void *extrav) {
struct extra_verify *e=extrav;
struct extra_verify *e = cast_to_typeof(e) extrav;
e->totalbytes += key->size + data->size;
e->rowcounter++;
assert(e->k.size == key->size);
......
......@@ -376,7 +376,7 @@ static int print_usage (const char *argv0) {
fprintf(stderr, " --periter N how many insertions per iteration (default=%d)\n", DEFAULT_ITEMS_TO_INSERT_PER_ITERATION);
fprintf(stderr, " --env DIR\n");
fprintf(stderr, " --append append to an existing file\n");
fprintf(stderr, " --checkpoint-period %"PRIu32" checkpoint period\n", checkpoint_period);
fprintf(stderr, " --checkpoint-period %" PRIu32 " checkpoint period\n", checkpoint_period);
fprintf(stderr, " n_iterations how many iterations (default %lld)\n", default_n_items/DEFAULT_ITEMS_TO_INSERT_PER_ITERATION);
return 1;
......
......@@ -260,7 +260,7 @@ static void scanscan_range (void) {
r = dbc->c_get(dbc, &key, &val, DB_SET_RANGE+lock_flag);
if (r != 0) {
assert(r == DB_NOTFOUND);
printf("%s:%d %"PRIu64"\n", __FUNCTION__, __LINE__, k);
printf("%s:%d %" PRIu64 "\n", __FUNCTION__, __LINE__, k);
goto makekey;
}
......@@ -280,7 +280,7 @@ static void scanscan_range (void) {
assert(r==0);
texperiments[counter] = gettime() - tstart;
printf("%"PRIu64" %f\n", k, texperiments[counter]); fflush(stdout);
printf("%" PRIu64 " %f\n", k, texperiments[counter]); fflush(stdout);
}
// print the times
......
......@@ -129,8 +129,8 @@ block_allocator_merge_blockpairs_into (u_int64_t d, struct block_allocator
static int
compare_blockpairs (const void *av, const void *bv) {
const struct block_allocator_blockpair *a = av;
const struct block_allocator_blockpair *b = bv;
const struct block_allocator_blockpair *a = (const struct block_allocator_blockpair *) av;
const struct block_allocator_blockpair *b = (const struct block_allocator_blockpair *) bv;
if (a->offset < b->offset) return -1;
if (a->offset > b->offset) return +1;
return 0;
......@@ -156,7 +156,7 @@ block_allocator_alloc_blocks_at (BLOCK_ALLOCATOR ba, u_int64_t n_blocks, struct
void
block_allocator_alloc_block_at (BLOCK_ALLOCATOR ba, u_int64_t size, u_int64_t offset) {
struct block_allocator_blockpair p = {.size = size, .offset=offset};
struct block_allocator_blockpair p = {.offset = offset, .size=size};
// Just do a linear search for the block.
// This data structure is a sorted array (no gaps or anything), so the search isn't really making this any slower than the insertion.
// To speed up the insertion when opening a file, we provide the block_allocator_alloc_blocks_at function.
......
......@@ -222,7 +222,7 @@ toku_block_translation_note_start_checkpoint_unlocked (BLOCK_TABLE bt) {
bt->checkpoint_failed = FALSE;
}
//#define PRNTF(str, b, siz, ad, bt) printf("%s[%d] %s %"PRId64" %"PRId64" %"PRId64"\n", __FUNCTION__, __LINE__, str, b, siz, ad); fflush(stdout); if (bt) block_allocator_validate(((BLOCK_TABLE)(bt))->block_allocator);
//#define PRNTF(str, b, siz, ad, bt) printf("%s[%d] %s %" PRId64 " %" PRId64 " %" PRId64 "\n", __FUNCTION__, __LINE__, str, b, siz, ad); fflush(stdout); if (bt) block_allocator_validate(((BLOCK_TABLE)(bt))->block_allocator);
//Debugging function
#define PRNTF(str, b, siz, ad, bt)
......@@ -287,22 +287,24 @@ toku_block_translation_note_end_checkpoint (BLOCK_TABLE bt, int fd) {
assert(bt->inprogress.block_translation[RESERVED_BLOCKNUM_TRANSLATION].size > 0);
assert(bt->inprogress.block_translation[RESERVED_BLOCKNUM_TRANSLATION].u.diskoff > 0);
int64_t i;
struct translation *t = &bt->checkpointed;
for (i = 0; i < t->length_of_array; i++) {
struct block_translation_pair *pair = &t->block_translation[i];
if (pair->size > 0 && !translation_prevents_freeing(&bt->inprogress, make_blocknum(i), pair)) {
assert(!translation_prevents_freeing(&bt->current, make_blocknum(i), pair));
PRNTF("free", i, pair->size, pair->u.diskoff, bt);
block_allocator_free_block(bt->block_allocator, pair->u.diskoff);
{
int64_t i;
struct translation *t = &bt->checkpointed;
for (i = 0; i < t->length_of_array; i++) {
struct block_translation_pair *pair = &t->block_translation[i];
if (pair->size > 0 && !translation_prevents_freeing(&bt->inprogress, make_blocknum(i), pair)) {
assert(!translation_prevents_freeing(&bt->current, make_blocknum(i), pair));
PRNTF("free", i, pair->size, pair->u.diskoff, bt);
block_allocator_free_block(bt->block_allocator, pair->u.diskoff);
}
}
toku_free(bt->checkpointed.block_translation);
bt->checkpointed = bt->inprogress;
bt->checkpointed.type = TRANSLATION_CHECKPOINTED;
memset(&bt->inprogress, 0, sizeof(bt->inprogress));
maybe_truncate_file(bt, fd, allocated_limit_at_start);
}
toku_free(bt->checkpointed.block_translation);
bt->checkpointed = bt->inprogress;
bt->checkpointed.type = TRANSLATION_CHECKPOINTED;
memset(&bt->inprogress, 0, sizeof(bt->inprogress));
maybe_truncate_file(bt, fd, allocated_limit_at_start);
end:
unlock_for_blocktable(bt);
}
......@@ -500,7 +502,7 @@ toku_serialize_translation_to_wbuf(BLOCK_TABLE bt, int fd, struct wbuf *w,
u_int64_t size_translation = calculate_size_on_disk(t);
assert((int64_t)size_translation==t->block_translation[b.b].size);
if (0)
printf("%s:%d writing translation table of size_translation %"PRIu64" at %"PRId64"\n", __FILE__, __LINE__, size_translation, t->block_translation[b.b].u.diskoff);
printf("%s:%d writing translation table of size_translation %" PRIu64 " at %" PRId64 "\n", __FILE__, __LINE__, size_translation, t->block_translation[b.b].u.diskoff);
wbuf_init(w, toku_malloc(size_translation), size_translation);
assert(w->size==size_translation);
}
......@@ -509,7 +511,7 @@ toku_serialize_translation_to_wbuf(BLOCK_TABLE bt, int fd, struct wbuf *w,
int64_t i;
for (i=0; i<t->smallest_never_used_blocknum.b; i++) {
if (0)
printf("%s:%d %"PRId64",%"PRId64"\n", __FILE__, __LINE__, t->block_translation[i].u.diskoff, t->block_translation[i].size);
printf("%s:%d %" PRId64 ",%" PRId64 "\n", __FILE__, __LINE__, t->block_translation[i].u.diskoff, t->block_translation[i].size);
wbuf_DISKOFF(w, t->block_translation[i].u.diskoff);
wbuf_DISKOFF(w, t->block_translation[i].size);
}
......@@ -678,14 +680,14 @@ static void
dump_translation(FILE *f, struct translation *t) {
if (t->block_translation) {
BLOCKNUM b = make_blocknum(RESERVED_BLOCKNUM_TRANSLATION);
fprintf(f, " length_of_array[%"PRId64"]", t->length_of_array);
fprintf(f, " smallest_never_used_blocknum[%"PRId64"]", t->smallest_never_used_blocknum.b);
fprintf(f, " blocknum_free_list_head[%"PRId64"]", t->blocknum_freelist_head.b);
fprintf(f, " size_on_disk[%"PRId64"]", t->block_translation[b.b].size);
fprintf(f, " location_on_disk[%"PRId64"]\n", t->block_translation[b.b].u.diskoff);
fprintf(f, " length_of_array[%" PRId64 "]", t->length_of_array);
fprintf(f, " smallest_never_used_blocknum[%" PRId64 "]", t->smallest_never_used_blocknum.b);
fprintf(f, " blocknum_free_list_head[%" PRId64 "]", t->blocknum_freelist_head.b);
fprintf(f, " size_on_disk[%" PRId64 "]", t->block_translation[b.b].size);
fprintf(f, " location_on_disk[%" PRId64 "]\n", t->block_translation[b.b].u.diskoff);
int64_t i;
for (i=0; i<t->length_of_array; i++) {
fprintf(f, " %"PRId64": %"PRId64" %"PRId64"\n", i, t->block_translation[i].u.diskoff, t->block_translation[i].size);
fprintf(f, " %" PRId64 ": %" PRId64 " %" PRId64 "\n", i, t->block_translation[i].u.diskoff, t->block_translation[i].size);
}
fprintf(f, "\n");
}
......@@ -832,11 +834,12 @@ blocktable_note_translation (BLOCK_ALLOCATOR allocator, struct translation *t) {
u_int64_t n_pairs = 0;
for (int64_t i=0; i<t->smallest_never_used_blocknum.b; i++) {
struct block_translation_pair pair = t->block_translation[i];
if (pair.size > 0) {
if (pair.size > 0) {
assert(pair.u.diskoff != diskoff_unused);
pairs[n_pairs++] = (struct block_allocator_blockpair){.size = pair.size,
.offset = pair.u.diskoff};
}
int cur_pair = n_pairs++;
pairs[cur_pair] = (struct block_allocator_blockpair) { .offset = (uint64_t) pair.u.diskoff,
.size = (uint64_t) pair.size };
}
}
block_allocator_alloc_blocks_at(allocator, n_pairs, pairs);
toku_free(pairs);
......@@ -924,7 +927,7 @@ typedef struct {
static int
frag_helper(BLOCKNUM UU(b), int64_t size, int64_t address, void *extra) {
frag_extra *info = extra;
frag_extra *info = (frag_extra *) extra;
if (size + address > info->total_space)
info->total_space = size + address;
......
This diff is collapsed.
......@@ -306,9 +306,9 @@ toku_checkpoint(CACHETABLE ct, TOKULOGGER logger,
void __attribute__((__constructor__)) toku_checkpoint_helgrind_ignore(void);
void
toku_checkpoint_helgrind_ignore(void) {
VALGRIND_HG_DISABLE_CHECKING(&cp_status, sizeof cp_status);
VALGRIND_HG_DISABLE_CHECKING(&locked_mo, sizeof locked_mo);
VALGRIND_HG_DISABLE_CHECKING(&locked_cs, sizeof locked_cs);
HELGRIND_VALGRIND_HG_DISABLE_CHECKING(&cp_status, sizeof cp_status);
HELGRIND_VALGRIND_HG_DISABLE_CHECKING(&locked_mo, sizeof locked_mo);
HELGRIND_VALGRIND_HG_DISABLE_CHECKING(&locked_cs, sizeof locked_cs);
}
#undef SET_CHECKPOINT_FOOTPRINT
......
......@@ -124,7 +124,7 @@ static void* io_thread (void *v)
//printf("%s:%d readcode=%ld\n", __FILE__, __LINE__, readcode);
if (readcode==-1) {
// a real error. Save the real error.
int the_errno = errno;
int the_errno = get_error_errno();
fprintf(stderr, "%s:%d dbf=%p fd=%d errno=%d\n", __FILE__, __LINE__, dbf, dbf->fd, the_errno);
dbf->error_code[1] = the_errno;
dbf->n_in_buf[1] = 0;
......@@ -164,12 +164,12 @@ static void* io_thread (void *v)
int create_dbufio_fileset (DBUFIO_FILESET *bfsp, int N, int fds[/*N*/], size_t bufsize) {
//printf("%s:%d here\n", __FILE__, __LINE__);
int result = 0;
DBUFIO_FILESET bfs=MALLOC(bfs);
if (bfs==0) { result = errno; }
DBUFIO_FILESET MALLOC(bfs);
if (bfs==0) { result = get_error_errno(); }
BOOL mutex_inited = FALSE, cond_inited = FALSE;
if (result==0) {
MALLOC_N(N, bfs->files);
if (bfs->files==NULL) { result = errno; }
if (bfs->files==NULL) { result = get_error_errno(); }
else {
for (int i=0; i<N; i++) {
bfs->files[i].buf[0] = bfs->files[i].buf[1] = NULL;
......@@ -198,7 +198,7 @@ int create_dbufio_fileset (DBUFIO_FILESET *bfsp, int N, int fds[/*N*/], size_t b
for (int j=0; j<2; j++) {
if (result==0) {
MALLOC_N(bufsize, bfs->files[i].buf[j]);
if (bfs->files[i].buf[j]==NULL) { result=errno; }
if (bfs->files[i].buf[j]==NULL) { result=get_error_errno(); }
}
bfs->files[i].n_in_buf[j] = 0;
bfs->files[i].error_code[j] = 0;
......@@ -207,7 +207,7 @@ int create_dbufio_fileset (DBUFIO_FILESET *bfsp, int N, int fds[/*N*/], size_t b
{
ssize_t r = toku_os_read(bfs->files[i].fd, bfs->files[i].buf[0], bufsize);
if (r<0) {
result=errno;
result=get_error_errno();
break;
} else if (r==0) {
// it's EOF
......@@ -360,7 +360,7 @@ dbufio_print(DBUFIO_FILESET bfs) {
fprintf(stderr, "%s:%d bfs=%p", __FILE__, __LINE__, bfs);
if (bfs->panic)
fprintf(stderr, " panic=%d", bfs->panic_errno);
fprintf(stderr, " N=%d %d %"PRIuMAX, bfs->N, bfs->n_not_done, bfs->bufsize);
fprintf(stderr, " N=%d %d %" PRIuMAX, bfs->N, bfs->n_not_done, bfs->bufsize);
for (int i = 0; i < bfs->N; i++) {
struct dbufio_file *dbf = &bfs->files[i];
if (dbf->error_code[0] || dbf->error_code[1])
......
......@@ -65,7 +65,7 @@ int toku_fifo_enq(FIFO fifo, const void *key, unsigned int keylen, const void *d
int need_space_total = fifo->memory_used+need_space_here;
if (fifo->memory == NULL) {
fifo->memory_size = next_power_of_two(need_space_total);
fifo->memory = toku_xmalloc(fifo->memory_size);
XMALLOC_N(fifo->memory_size, fifo->memory);
}
if (need_space_total > fifo->memory_size) {
// Out of memory at the end.
......@@ -73,7 +73,7 @@ int toku_fifo_enq(FIFO fifo, const void *key, unsigned int keylen, const void *d
if ((2*next_2 > fifo->memory_size)
|| (8*next_2 < fifo->memory_size)) {
// resize the fifo
char *newmem = toku_xmalloc(next_2);
char *XMALLOC_N(next_2, newmem);
char *oldmem = fifo->memory;
if (newmem==0) return ENOMEM;
memcpy(newmem, oldmem, fifo->memory_used);
......@@ -144,7 +144,7 @@ void toku_fifo_clone(FIFO orig_fifo, FIFO* cloned_fifo) {
new_fifo->n_items_in_fifo = orig_fifo->n_items_in_fifo;
new_fifo->memory_used = orig_fifo->memory_used;
new_fifo->memory_size = new_fifo->memory_used;
new_fifo->memory = toku_xmalloc(new_fifo->memory_size);
XMALLOC_N(new_fifo->memory_size, new_fifo->memory);
memcpy(
new_fifo->memory,
orig_fifo->memory,
......@@ -159,4 +159,3 @@ BOOL toku_are_fifos_same(FIFO fifo1, FIFO fifo2) {
memcmp(fifo1->memory, fifo2->memory, fifo1->memory_used) == 0
);
}
......@@ -16,7 +16,7 @@ ftnode_get_key_and_fullhash(
u_int32_t* fullhash,
void* extra)
{
FT h = extra;
FT h = (FT) extra;
BLOCKNUM name;
toku_allocate_blocknum(h->blocktable, &name, h);
*cachekey = name;
......@@ -148,7 +148,7 @@ toku_pin_ftnode(
bfe, //read_extraargs
unlockers);
if (r==0) {
FTNODE node = node_v;
FTNODE node = (FTNODE) node_v;
if (apply_ancestor_messages) {
maybe_apply_ancestors_messages_to_node(brt, node, ancestors, bounds, msgs_applied);
}
......@@ -203,7 +203,7 @@ toku_pin_ftnode_off_client_thread(
dependent_dirty_bits
);
assert(r==0);
FTNODE node = node_v;
FTNODE node = (FTNODE) node_v;
*node_p = node;
}
......
......@@ -13,7 +13,7 @@
/* Status is intended for display to humans to help understand system behavior.
* It does not need to be perfectly thread-safe.
*/
static volatile FT_FLUSHER_STATUS_S ft_flusher_status;
static FT_FLUSHER_STATUS_S ft_flusher_status;
#define STATUS_INIT(k, t, l) { \
ft_flusher_status.status[k].keyname = #k; \
......@@ -274,7 +274,7 @@ flt_update_status(FTNODE child,
int UU(dirtied),
void* extra)
{
struct flush_status_update_extra *fste = extra;
struct flush_status_update_extra *fste = (struct flush_status_update_extra *) extra;
update_flush_status(child, fste->cascades);
// If `flush_some_child` decides to recurse after this, we'll need
// cascades to increase. If not it doesn't matter.
......@@ -305,7 +305,7 @@ ctm_pick_child(FT h,
FTNODE parent,
void* extra)
{
struct ctm_extra* ctme = extra;
struct ctm_extra* ctme = (struct ctm_extra *) extra;
int childnum;
if (parent->height == 1 && ctme->is_last_child) {
childnum = parent->n_children - 1;
......@@ -424,7 +424,7 @@ ct_update_status(FTNODE child,
int dirtied,
void* extra)
{
struct flush_status_update_extra* fste = extra;
struct flush_status_update_extra* fste = (struct flush_status_update_extra *) extra;
update_flush_status(child, fste->cascades);
STATUS_VALUE(FT_FLUSHER_CLEANER_NODES_DIRTIED) += dirtied;
// Incrementing this in case `flush_some_child` decides to recurse.
......@@ -549,8 +549,8 @@ handle_split_of_child(
static int
verify_in_mempool(OMTVALUE lev, u_int32_t UU(idx), void *vmp)
{
LEAFENTRY le = lev;
struct mempool *mp = vmp;
LEAFENTRY le = (LEAFENTRY) lev;
struct mempool *mp = (struct mempool *) vmp;
lazy_assert(toku_mempool_inrange(mp, le, leafentry_memsize(le)));
return 0;
}
......@@ -583,7 +583,7 @@ ftleaf_disk_size(FTNODE node)
OMTVALUE v;
LEAFENTRY curr_le = NULL;
int r = toku_omt_fetch(curr_buffer, j, &v);
curr_le = v;
curr_le = (LEAFENTRY) v;
assert_zero(r);
retval += leafentry_disksize(curr_le);
}
......@@ -613,7 +613,7 @@ ftleaf_get_split_loc(
LEAFENTRY curr_le = NULL;
OMTVALUE v;
int r = toku_omt_fetch(curr_buffer, j, &v);
curr_le = v;
curr_le = (LEAFENTRY) v;
assert_zero(r);
size_so_far += leafentry_disksize(curr_le);
if (size_so_far >= sumlesizes/2) {
......@@ -678,7 +678,7 @@ move_leafentries(
curr_le = fetch_from_buf(src_bn->buffer, i);
size_t le_size = leafentry_memsize(curr_le);
*num_bytes_moved += leafentry_disksize(curr_le);
LEAFENTRY new_le = toku_mempool_malloc(dest_mp, le_size, 1);
LEAFENTRY new_le = (LEAFENTRY) toku_mempool_malloc(dest_mp, le_size, 1);
memcpy(new_le, curr_le, le_size);
newleafpointers[i-lbi] = new_le;
toku_mempool_mfree(src_mp, curr_le, le_size);
......@@ -887,7 +887,7 @@ ftleaf_split(
OMTVALUE lev = 0;
int r=toku_omt_fetch(BLB_BUFFER(node, last_bn_on_left), toku_omt_size(BLB_BUFFER(node, last_bn_on_left))-1, &lev);
assert_zero(r); // that fetch should have worked.
LEAFENTRY le=lev;
LEAFENTRY le = (LEAFENTRY) lev;
uint32_t keylen;
void *key = le_key_and_len(le, &keylen);
toku_fill_dbt(splitk, toku_xmemdup(key, keylen), keylen);
......@@ -1314,7 +1314,7 @@ static void merge_remove_key_callback(
BOOL for_checkpoint,
void *extra)
{
FT h = extra;
FT h = (FT) extra;
toku_free_blocknum(h->blocktable, bp, h, for_checkpoint);
}
......@@ -1673,11 +1673,11 @@ toku_ftnode_cleaner_callback(
u_int32_t fullhash,
void *extraargs)
{
FTNODE node = ftnode_pv;
FTNODE node = (FTNODE) ftnode_pv;
invariant(node->thisnodename.b == blocknum.b);
invariant(node->fullhash == fullhash);
invariant(node->height > 0); // we should never pick a leaf node (for now at least)
FT h = extraargs;
FT h = (FT) extraargs;
bring_node_fully_into_memory(node, h);
int childnum = find_heaviest_child(node);
update_cleaner_status(node, childnum);
......@@ -1708,7 +1708,7 @@ struct flusher_extra {
static void flush_node_fun(void *fe_v)
{
int r;
struct flusher_extra* fe = fe_v;
struct flusher_extra* fe = (struct flusher_extra *) fe_v;
// The node that has been placed on the background
// thread may not be fully in memory. Some message
// buffers may be compressed. Before performing
......@@ -1768,9 +1768,7 @@ place_node_and_bnc_on_background_thread(
FTNODE node,
NONLEAF_CHILDINFO bnc)
{
struct flusher_extra* fe = NULL;
fe = toku_xmalloc(sizeof(struct flusher_extra));
assert(fe);
struct flusher_extra *XMALLOC(fe);
fe->h = h;
fe->node = node;
fe->bnc = bnc;
......@@ -1821,7 +1819,7 @@ flush_node_on_background_thread(FT h, FTNODE parent)
//
// successfully locked child
//
child = node_v;
child = (FTNODE) node_v;
bool may_child_be_reactive = may_node_be_reactive(child);
if (!may_child_be_reactive) {
// We're going to unpin the parent, so before we do, we must
......@@ -1862,7 +1860,7 @@ flush_node_on_background_thread(FT h, FTNODE parent)
void __attribute__((__constructor__)) toku_ft_flusher_helgrind_ignore(void);
void
toku_ft_flusher_helgrind_ignore(void) {
VALGRIND_HG_DISABLE_CHECKING(&ft_flusher_status, sizeof ft_flusher_status);
HELGRIND_VALGRIND_HG_DISABLE_CHECKING(&ft_flusher_status, sizeof ft_flusher_status);
}
#undef STATUS_VALUE
......@@ -29,7 +29,7 @@ struct hot_flusher_extra {
bool rightmost_leaf_seen;
};
static volatile FT_HOT_STATUS_S hot_status;
static FT_HOT_STATUS_S hot_status;
#define STATUS_INIT(k,t,l) { \
hot_status.status[k].keyname = #k; \
......@@ -147,7 +147,7 @@ hot_pick_child(FT h,
FTNODE parent,
void *extra)
{
struct hot_flusher_extra *flusher = extra;
struct hot_flusher_extra *flusher = (struct hot_flusher_extra *) extra;
int childnum = hot_just_pick_child(h, parent, flusher);
// Now we determine the percentage of the tree flushed so far.
......@@ -184,7 +184,7 @@ hot_pick_child_after_split(FT h,
int childnumb,
void *extra)
{
struct hot_flusher_extra *flusher = extra;
struct hot_flusher_extra *flusher = (struct hot_flusher_extra *) extra;
int childnum = hot_just_pick_child(h, parent, flusher);
assert(childnum == childnuma || childnum == childnumb);
hot_update_flusher_keys(parent, childnum, flusher);
......@@ -370,7 +370,7 @@ void __attribute__((__constructor__)) toku_hot_helgrind_ignore(void);
void
toku_hot_helgrind_ignore(void) {
// incremented only while lock is held, but read by engine status asynchronously.
VALGRIND_HG_DISABLE_CHECKING(&hot_status, sizeof hot_status);
HELGRIND_VALGRIND_HG_DISABLE_CHECKING(&hot_status, sizeof hot_status);
}
......
......@@ -395,9 +395,8 @@ struct ft_header {
uint32_t count_of_optimize_in_progress_read_from_disk;
// all messages before this msn have been applied to leaf nodes
MSN msn_at_start_of_last_completed_optimize;
STAT64INFO_S on_disk_stats;
STAT64INFO_S on_disk_stats;
};
// brt_header is always the current version.
......@@ -467,9 +466,8 @@ struct ft {
// Copy the descriptor into a temporary variable, and tell DRD that subsequent code happens after reading that pointer.
// In combination with the annotation in toku_ft_update_descriptor, this seems to be enough to convince test_4015 that all is well.
// Otherwise, drd complains that the newly malloc'd descriptor string is touched later by some comparison operation.
static const struct __toku_db zero_db; // it's static, so it's all zeros. icc needs this to be a global
static inline void setup_fake_db (DB *fake_db, DESCRIPTOR orig_desc) {
*fake_db = zero_db;
memset(fake_db, 0, sizeof *fake_db);
fake_db->cmp_descriptor = orig_desc;
}
#define FAKE_DB(db, desc) struct __toku_db db; setup_fake_db(&db, (desc))
......@@ -567,7 +565,6 @@ int check_legacy_end_checksum(struct rbuf *rb);
/* End of ft-node-deserialization.c helper functions. */
unsigned int toku_serialize_ftnode_size(FTNODE node); /* How much space will it take? */
int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len);
void toku_verify_or_set_counts(FTNODE);
......@@ -854,8 +851,8 @@ int toku_testsetup_leaf(FT_HANDLE brt, BLOCKNUM *blocknum, int n_children, char
int toku_testsetup_nonleaf (FT_HANDLE brt, int height, BLOCKNUM *diskoff, int n_children, BLOCKNUM *children, char **keys, int *keylens);
int toku_testsetup_root(FT_HANDLE brt, BLOCKNUM);
int toku_testsetup_get_sersize(FT_HANDLE brt, BLOCKNUM); // Return the size on disk.
int toku_testsetup_insert_to_leaf (FT_HANDLE brt, BLOCKNUM, char *key, int keylen, char *val, int vallen);
int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM, enum ft_msg_type, char *key, int keylen, char *val, int vallen);
int toku_testsetup_insert_to_leaf (FT_HANDLE brt, BLOCKNUM, const char *key, int keylen, const char *val, int vallen);
int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM, enum ft_msg_type, const char *key, int keylen, const char *val, int vallen);
void toku_pin_node_with_min_bfe(FTNODE* node, BLOCKNUM b, FT_HANDLE t);
// These two go together to do lookups in a ftnode using the keys in a command.
......
......@@ -21,8 +21,8 @@
*/
// Sets initial values for the given fractal tree node to be
// desiralized
inline void
// deserialized
void
initialize_ftnode(FTNODE node, BLOCKNUM blocknum)
{
node->fullhash = 0xDEADBEEF; // <CER> Is this 'spoof' ok?
......@@ -92,8 +92,7 @@ allocate_and_read_partition_offsets(FTNODE node, struct rbuf *rb, FTNODE_DISK_DA
{
XMALLOC_N(node->n_children, node->bp);
// TODO: Fix this to use xmalloc_n
// XMALLOC_N(node->n_children, *ndd);
*ndd = toku_xmalloc(node->n_children * sizeof(**ndd));
XMALLOC_N(node->n_children, *ndd);
// Read the partition locations.
for (int i = 0; i < node->n_children; i++) {
BP_START(*ndd, i) = rbuf_int(rb);
......
This diff is collapsed.
......@@ -166,7 +166,7 @@ int toku_ft_send_commit_any(FT_HANDLE brt, DBT *key, XIDS xids) __attribute__ ((
int toku_close_ft_handle_nolsn (FT_HANDLE, char **error_string) __attribute__ ((warn_unused_result));
int toku_ft_handle_set_panic(FT_HANDLE brt, int panic, char *panic_string) __attribute__ ((warn_unused_result));
int toku_ft_handle_set_panic(FT_HANDLE brt, int panic, const char *panic_string) __attribute__ ((warn_unused_result));
int toku_dump_ft (FILE *,FT_HANDLE brt) __attribute__ ((warn_unused_result));
......
This diff is collapsed.
......@@ -97,12 +97,13 @@ int toku_testsetup_get_sersize(FT_HANDLE brt, BLOCKNUM diskoff) // Return the si
&bfe
);
assert(r==0);
int size = toku_serialize_ftnode_size(node_v);
toku_unpin_ftnode(brt->ft, node_v);
FTNODE node = cast_to_typeof(node) node_v;
int size = toku_serialize_ftnode_size(node);
toku_unpin_ftnode(brt->ft, node);
return size;
}
int toku_testsetup_insert_to_leaf (FT_HANDLE brt, BLOCKNUM blocknum, char *key, int keylen, char *val, int vallen) {
int toku_testsetup_insert_to_leaf (FT_HANDLE brt, BLOCKNUM blocknum, const char *key, int keylen, const char *val, int vallen) {
void *node_v;
int r;
......@@ -124,15 +125,15 @@ int toku_testsetup_insert_to_leaf (FT_HANDLE brt, BLOCKNUM blocknum, char *key,
&bfe
);
if (r!=0) return r;
FTNODE node=node_v;
FTNODE node = cast_to_typeof(node) node_v;
toku_verify_or_set_counts(node);
assert(node->height==0);
DBT keydbt,valdbt;
MSN msn = next_dummymsn();
FT_MSG_S cmd = {FT_INSERT, msn, xids_get_root_xids(),
.u.id={toku_fill_dbt(&keydbt, key, keylen),
toku_fill_dbt(&valdbt, val, vallen)}};
FT_MSG_S cmd = { FT_INSERT, msn, xids_get_root_xids(),
.u = { .id = { toku_fill_dbt(&keydbt, key, keylen),
toku_fill_dbt(&valdbt, val, vallen) } } };
toku_ft_node_put_cmd (
brt->ft->compare_fun,
......@@ -146,14 +147,14 @@ int toku_testsetup_insert_to_leaf (FT_HANDLE brt, BLOCKNUM blocknum, char *key,
toku_verify_or_set_counts(node);
toku_unpin_ftnode(brt->ft, node_v);
toku_unpin_ftnode(brt->ft, node);
return 0;
}
static int
testhelper_string_key_cmp(DB *UU(e), const DBT *a, const DBT *b)
{
char *s = a->data, *t = b->data;
char *s = cast_to_typeof(s) a->data, *t = cast_to_typeof(t) b->data;
return strcmp(s, t);
}
......@@ -175,7 +176,7 @@ toku_pin_node_with_min_bfe(FTNODE* node, BLOCKNUM b, FT_HANDLE t)
);
}
int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM blocknum, enum ft_msg_type cmdtype, char *key, int keylen, char *val, int vallen) {
int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM blocknum, enum ft_msg_type cmdtype, const char *key, int keylen, const char *val, int vallen) {
void *node_v;
int r;
......@@ -197,7 +198,7 @@ int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM blocknum, enum ft_
&bfe
);
if (r!=0) return r;
FTNODE node=node_v;
FTNODE node = cast_to_typeof(node) node_v;
assert(node->height>0);
DBT k;
......@@ -215,6 +216,6 @@ int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM blocknum, enum ft_
node->max_msn_applied_to_node_on_disk = msn;
node->dirty = 1;
toku_unpin_ftnode(brt->ft, node_v);
toku_unpin_ftnode(brt->ft, node);
return 0;
}
......@@ -108,7 +108,7 @@ struct count_msgs_extra {
static int
count_msgs(OMTVALUE v, u_int32_t UU(idx), void *ve)
{
struct count_msgs_extra *e = ve;
struct count_msgs_extra *e = cast_to_typeof(e) ve;
long offset = (long) v;
const struct fifo_entry *entry = toku_fifo_get_entry(e->fifo, offset);
if (entry->msn.msn == e->msn.msn) {
......@@ -130,7 +130,7 @@ struct verify_message_tree_extra {
static int
verify_message_tree(OMTVALUE v, u_int32_t UU(idx), void *ve)
{
struct verify_message_tree_extra *e = ve;
struct verify_message_tree_extra *e = cast_to_typeof(e) ve;
int verbose = e->verbose;
BLOCKNUM blocknum = e->blocknum;
int keep_going_on_failure = e->keep_going_on_failure;
......
......@@ -54,7 +54,7 @@ ft_copy_for_checkpoint_unlocked(FT ft, LSN checkpoint_lsn) {
assert(ft->checkpoint_header == NULL);
assert(ft->panic==0);
FT_HEADER ch = toku_xmemdup(ft->h, sizeof *ft->h);
FT_HEADER XMEMDUP(ch, ft->h);
ch->type = FT_CHECKPOINT_INPROGRESS; //Different type
//printf("checkpoint_lsn=%" PRIu64 "\n", checkpoint_lsn.lsn);
ch->checkpoint_lsn = checkpoint_lsn;
......@@ -116,10 +116,10 @@ toku_ft_release_reflock(FT ft) {
// maps to cf->log_fassociate_during_checkpoint
static int
ft_log_fassociate_during_checkpoint (CACHEFILE cf, void *header_v) {
FT ft = header_v;
FT ft = (FT) header_v;
char* fname_in_env = toku_cachefile_fname_in_env(cf);
BYTESTRING bs = { strlen(fname_in_env), // don't include the NUL
fname_in_env };
BYTESTRING bs = { .len = (uint32_t) strlen(fname_in_env), // don't include the NUL
.data = fname_in_env };
TOKULOGGER logger = toku_cachefile_logger(cf);
FILENUM filenum = toku_cachefile_filenum(cf);
bool unlink_on_close = toku_cachefile_is_unlink_on_close(cf);
......@@ -131,7 +131,7 @@ ft_log_fassociate_during_checkpoint (CACHEFILE cf, void *header_v) {
static int
ft_log_suppress_rollback_during_checkpoint (CACHEFILE cf, void *header_v) {
int r = 0;
FT h = header_v;
FT h = (FT) header_v;
TXNID xid = h->txnid_that_created_or_locked_when_empty;
if (xid != TXNID_NONE) {
//Only log if useful.
......@@ -152,7 +152,7 @@ ft_log_suppress_rollback_during_checkpoint (CACHEFILE cf, void *header_v) {
// Not reentrant for a single FT (see ft_checkpoint)
static int
ft_begin_checkpoint (LSN checkpoint_lsn, void *header_v) {
FT ft = header_v;
FT ft = (FT) header_v;
int r = ft->panic;
if (r==0) {
// hold lock around copying and clearing of dirty bit
......@@ -198,7 +198,7 @@ ft_hack_highest_unused_msn_for_upgrade_for_checkpoint(FT ft) {
// end_checkpoint is not reentrant period
static int
ft_checkpoint (CACHEFILE cf, int fd, void *header_v) {
FT ft = header_v;
FT ft = (FT) header_v;
FT_HEADER ch = ft->checkpoint_header;
int r = 0;
if (ft->panic!=0) goto handle_error;
......@@ -249,7 +249,7 @@ handle_error:
// Must have access to fd (protected)
static int
ft_end_checkpoint (CACHEFILE UU(cachefile), int fd, void *header_v) {
FT ft = header_v;
FT ft = (FT) header_v;
int r = ft->panic;
if (r==0) {
assert(ft->h->type == FT_CURRENT);
......@@ -266,7 +266,7 @@ ft_end_checkpoint (CACHEFILE UU(cachefile), int fd, void *header_v) {
// Has access to fd (it is protected).
static int
ft_close (CACHEFILE cachefile, int fd, void *header_v, char **malloced_error_string, BOOL oplsn_valid, LSN oplsn) {
FT ft = header_v;
FT ft = (FT) header_v;
assert(ft->h->type == FT_CURRENT);
// We already have exclusive access to this field already, so skip the locking.
// This should already never fail.
......@@ -292,7 +292,7 @@ ft_close (CACHEFILE cachefile, int fd, void *header_v, char **malloced_error_str
if (logger) {
char* fname_in_env = toku_cachefile_fname_in_env(cachefile);
assert(fname_in_env);
BYTESTRING bs = {.len=strlen(fname_in_env), .data=fname_in_env};
BYTESTRING bs = {.len=(uint32_t) strlen(fname_in_env), .data=fname_in_env};
r = toku_log_fclose(logger, &lsn, ft->h->dirty, bs, toku_cachefile_filenum(cachefile)); // flush the log on close (if new header is being written), otherwise it might not make it out.
if (r!=0) return r;
}
......@@ -329,7 +329,7 @@ ft_note_pin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v)
{
//Set arbitrary brt (for given header) as pinned by checkpoint.
//Only one can be pinned (only one checkpoint at a time), but not worth verifying.
FT ft = header_v;
FT ft = (FT) header_v;
// Note: open_close lock is held by checkpoint begin
toku_ft_grab_reflock(ft);
......@@ -355,7 +355,7 @@ unpin_by_checkpoint_callback(FT ft, void *extra)
static int
ft_note_unpin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v)
{
FT ft = header_v;
FT ft = (FT) header_v;
toku_ft_remove_reference(ft, false, ZERO_LSN, unpin_by_checkpoint_callback, NULL);
return 0;
}
......@@ -451,7 +451,7 @@ ft_header_new(FT_OPTIONS options, BLOCKNUM root_blocknum, TXNID root_xid_that_cr
.msn_at_start_of_last_completed_optimize = ZERO_MSN,
.on_disk_stats = ZEROSTATS
};
return toku_xmemdup(&h, sizeof h);
return (FT_HEADER) toku_xmemdup(&h, sizeof h);
}
// allocate and initialize a fractal tree.
......@@ -500,7 +500,7 @@ int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_ac
{
{
FT h;
if ((h=toku_cachefile_get_userdata(cf))!=0) {
if ((h = (FT) toku_cachefile_get_userdata(cf))!=0) {
*header = h;
*was_open = TRUE;
assert(brt->options.update_fun == h->update_fun);
......@@ -649,7 +649,9 @@ toku_ft_init(FT ft,
.nodesize = target_nodesize,
.basementnodesize = target_basementnodesize,
.compression_method = compression_method,
.flags = 0
.flags = 0,
.compare_fun = NULL,
.update_fun = NULL
};
ft->h = ft_header_new(&options, root_blocknum_on_disk, root_xid_that_created);
ft->h->checkpoint_count = 1;
......@@ -880,7 +882,7 @@ LSN toku_ft_checkpoint_lsn(FT ft) {
return ft->h->checkpoint_lsn;
}
int toku_ft_set_panic(FT ft, int panic, char *panic_string) {
int toku_ft_set_panic(FT ft, int panic, const char *panic_string) {
if (ft->panic == 0) {
ft->panic = panic;
if (ft->panic_string) {
......
......@@ -74,7 +74,7 @@ void toku_ft_remove_txn_ref(FT h);
void toku_calculate_root_offset_pointer ( FT h, CACHEKEY* root_key, u_int32_t *roothash);
void toku_ft_set_new_root_blocknum(FT h, CACHEKEY new_root_key);
LSN toku_ft_checkpoint_lsn(FT h) __attribute__ ((warn_unused_result));
int toku_ft_set_panic(FT h, int panic, char *panic_string) __attribute__ ((warn_unused_result));
int toku_ft_set_panic(FT h, int panic, const char *panic_string) __attribute__ ((warn_unused_result));
void toku_ft_stat64 (FT h, struct ftstat64_s *s);
// unconditionally set the descriptor for an open FT. can't do this when
......
This diff is collapsed.
......@@ -48,7 +48,7 @@ static void
hex_dump(unsigned char *vp, u_int64_t offset, u_int64_t size) {
u_int64_t n = size / 32;
for (u_int64_t i = 0; i < n; i++) {
printf("%"PRIu64": ", offset);
printf("%" PRIu64 ": ", offset);
for (u_int64_t j = 0; j < 32; j++) {
unsigned char c = vp[j];
printf("%2.2X", c);
......@@ -66,7 +66,7 @@ hex_dump(unsigned char *vp, u_int64_t offset, u_int64_t size) {
size = size % 32;
for (u_int64_t i=0; i<size; i++) {
if ((i % 32) == 0)
printf("%"PRIu64": ", offset+i);
printf("%" PRIu64 ": ", offset+i);
printf("%2.2X", vp[i]);
if (((i+1) % 4) == 0)
printf(" ");
......@@ -79,13 +79,13 @@ hex_dump(unsigned char *vp, u_int64_t offset, u_int64_t size) {
static void
dump_descriptor(DESCRIPTOR d) {
printf(" descriptor size %u ", d->dbt.size);
simple_hex_dump(d->dbt.data, d->dbt.size);
simple_hex_dump((unsigned char*) d->dbt.data, d->dbt.size);
printf("\n");
}
static void
dump_header (int f, FT *header, CACHEFILE cf) {
FT ft;
FT ft = NULL;
int r;
char timestr[26];
r = toku_deserialize_ft_from (f, MAX_LSN, &ft);
......@@ -98,9 +98,9 @@ dump_header (int f, FT *header, CACHEFILE cf) {
printf(" build_id=%d\n", ft->h->build_id);
printf(" build_id_original=%d\n", ft->h->build_id_original);
format_time(ft->h->time_of_creation, timestr);
printf(" time_of_creation= %"PRIu64" %s\n", ft->h->time_of_creation, timestr);
printf(" time_of_creation= %" PRIu64 " %s\n", ft->h->time_of_creation, timestr);
format_time(ft->h->time_of_last_modification, timestr);
printf(" time_of_last_modification=%"PRIu64" %s\n", ft->h->time_of_last_modification, timestr);
printf(" time_of_last_modification=%" PRIu64 " %s\n", ft->h->time_of_last_modification, timestr);
printf(" dirty=%d\n", ft->h->dirty);
printf(" checkpoint_count=%" PRId64 "\n", ft->h->checkpoint_count);
printf(" checkpoint_lsn=%" PRId64 "\n", ft->h->checkpoint_lsn.lsn);
......@@ -117,7 +117,7 @@ dump_header (int f, FT *header, CACHEFILE cf) {
static int
print_le (OMTVALUE lev, u_int32_t UU(idx), void *UU(v)) {
LEAFENTRY le=lev;
LEAFENTRY le = cast_to_typeof(le) lev;
print_leafentry(stdout, le);
printf("\n");
return 0;
......@@ -147,7 +147,7 @@ dump_node (int f, BLOCKNUM blocknum, FT h) {
printf(" layout_version_original=%d\n", n->layout_version_original);
printf(" layout_version_read_from_disk=%d\n", n->layout_version_read_from_disk);
printf(" build_id=%d\n", n->build_id);
printf(" max_msn_applied_to_node_on_disk=%"PRId64" (0x%"PRIx64")\n", n->max_msn_applied_to_node_on_disk.msn, n->max_msn_applied_to_node_on_disk.msn);
printf(" max_msn_applied_to_node_on_disk=%" PRId64 " (0x%" PRIx64 ")\n", n->max_msn_applied_to_node_on_disk.msn, n->max_msn_applied_to_node_on_disk.msn);
printf(" n_children=%d\n", n->n_children);
printf(" total_childkeylens=%u\n", n->totalchildkeylens);
......@@ -173,7 +173,7 @@ dump_node (int f, BLOCKNUM blocknum, FT h) {
if (dump_data) {
FIFO_ITERATE(bnc->buffer, key, keylen, data, datalen, typ, msn, xids, UU(is_fresh),
{
printf(" msn=%"PRIu64" (0x%"PRIx64") ", msn.msn, msn.msn);
printf(" msn=%" PRIu64 " (0x%" PRIx64 ") ", msn.msn, msn.msn);
printf(" TYPE=");
switch ((enum ft_msg_type)typ) {
case FT_NONE: printf("NONE"); goto ok;
......@@ -229,7 +229,7 @@ typedef struct {
static int
fragmentation_helper(BLOCKNUM b, int64_t size, int64_t UU(address), void *extra) {
frag_help_extra *info = extra;
frag_help_extra *info = cast_to_typeof(info) extra;
FTNODE n;
FTNODE_DISK_DATA ndd = NULL;
struct ftnode_fetch_extra bfe;
......@@ -278,8 +278,8 @@ typedef struct {
static int
garbage_leafentry_helper(OMTVALUE v, u_int32_t UU(idx), void *extra) {
garbage_help_extra *info = extra;
LEAFENTRY le = v;
garbage_help_extra *info = cast_to_typeof(info) extra;
LEAFENTRY le = cast_to_typeof(le) v;
info->total_space += leafentry_disksize(le);
info->used_space += LE_CLEAN_MEMSIZE(le_latest_keylen(le), le_latest_vallen(le));
return 0;
......@@ -287,7 +287,7 @@ garbage_leafentry_helper(OMTVALUE v, u_int32_t UU(idx), void *extra) {
static int
garbage_helper(BLOCKNUM b, int64_t UU(size), int64_t UU(address), void *extra) {
garbage_help_extra *info = extra;
garbage_help_extra *info = cast_to_typeof(info) extra;
FTNODE n;
FTNODE_DISK_DATA ndd = NULL;
struct ftnode_fetch_extra bfe;
......@@ -380,21 +380,21 @@ verify_block(unsigned char *cp, u_int64_t file_offset, u_int64_t size) {
u_int32_t xsum = x1764_memory(cp + offset, sub_block[i].compressed_size);
printf("%u: %u %u %u", i, sub_block[i].compressed_size, sub_block[i].uncompressed_size, sub_block[i].xsum);
if (xsum != sub_block[i].xsum)
printf(" fail %u offset %"PRIu64, xsum, file_offset + offset);
printf(" fail %u offset %" PRIu64, xsum, file_offset + offset);
printf("\n");
offset += sub_block[i].compressed_size;
}
if (offset != size)
printf("offset %u expected %"PRIu64"\n", offset, size);
printf("offset %u expected %" PRIu64 "\n", offset, size);
}
static void
dump_block(int f, BLOCKNUM blocknum, FT h) {
DISKOFF offset, size;
toku_translate_blocknum_to_offset_size(h->blocktable, blocknum, &offset, &size);
printf("%"PRId64" at %"PRId64" size %"PRId64"\n", blocknum.b, offset, size);
printf("%" PRId64 " at %" PRId64 " size %" PRId64 "\n", blocknum.b, offset, size);
unsigned char *vp = toku_malloc(size);
unsigned char *vp = cast_to_typeof(vp) toku_malloc(size);
u_int64_t r = pread(f, vp, size, offset);
if (r == (u_int64_t)size) {
verify_block(vp, offset, size);
......@@ -404,7 +404,7 @@ dump_block(int f, BLOCKNUM blocknum, FT h) {
static void
dump_file(int f, u_int64_t offset, u_int64_t size, FILE *outfp) {
unsigned char *vp = toku_malloc(size);
unsigned char *XMALLOC_N(size, vp);
u_int64_t r = pread(f, vp, size, offset);
if (r == size) {
if (outfp == stdout)
......@@ -436,7 +436,12 @@ split_fields (char *line, char *fields[], int maxfields) {
int i;
for (i=0; i<maxfields; i++, line=NULL) {
fields[i] = strtok(line, " ");
if (fields[i] == NULL) break;
if (fields[i] == NULL) {
for (; i < maxfields; ++i) {
fields[i] = NULL;
}
break;
}
}
return i;
}
......@@ -454,7 +459,7 @@ typedef struct __dump_node_extra {
static int
dump_node_wrapper(BLOCKNUM b, int64_t UU(size), int64_t UU(address), void *extra) {
dump_node_extra *info = extra;
dump_node_extra *info = cast_to_typeof(info) extra;
dump_node(info->f, b, info->h);
return 0;
}
......@@ -510,7 +515,7 @@ main (int argc, const char *const argv[]) {
// create a cachefile for the header
int r = toku_create_cachetable(&ct, 1<<25, (LSN){0}, 0);
assert(r == 0);
CACHEFILE cf;
CACHEFILE cf = NULL;
r = toku_cachetable_openfd (&cf, ct, f, n);
assert(r==0);
dump_header(f, &ft, cf);
......
This diff is collapsed.
......@@ -74,7 +74,7 @@ typedef struct pair_attr_s {
long leaf_size; // size if PAIR is a leaf node, 0 otherwise, used only for engine status
long rollback_size; // size of PAIR is a rollback node, 0 otherwise, used only for engine status
long cache_pressure_size; // amount PAIR contributes to cache pressure, is sum of buffer sizes and workdone counts
BOOL is_valid;
bool is_valid;
} PAIR_ATTR;
static inline PAIR_ATTR make_pair_attr(long size) {
......
......@@ -77,7 +77,7 @@ report(int64_t blocks_done, int64_t blocks_failed, int64_t total_blocks)
}
if (blocks_done % blocks_per_report == 0) {
double pct_actually_done = (100.0 * blocks_done) / total_blocks;
printf("% 3.3lf%% | %"PRId64" blocks checked, %"PRId64" bad block(s) detected\n",
printf("% 3.3lf%% | %" PRId64 " blocks checked, %" PRId64 " bad block(s) detected\n",
pct_actually_done, blocks_done, blocks_failed);
fflush(stdout);
}
......@@ -135,7 +135,7 @@ deserialize_headers(int fd, struct ft **h1p, struct ft **h2p)
abort();
}
if (h0_acceptable) {
printf("Found dictionary header 1 with LSN %"PRIu64"\n", checkpoint_lsn_0.lsn);
printf("Found dictionary header 1 with LSN %" PRIu64 "\n", checkpoint_lsn_0.lsn);
r = deserialize_ft_versioned(fd, &rb_0, h1p, version_0);
if (r != 0) {
......@@ -146,7 +146,7 @@ deserialize_headers(int fd, struct ft **h1p, struct ft **h2p)
*h1p = NULL;
}
if (h1_acceptable) {
printf("Found dictionary header 2 with LSN %"PRIu64"\n", checkpoint_lsn_1.lsn);
printf("Found dictionary header 2 with LSN %" PRIu64 "\n", checkpoint_lsn_1.lsn);
r = deserialize_ft_versioned(fd, &rb_1, h2p, version_1);
if (r != 0) {
printf("---Header Error----\n");
......@@ -192,7 +192,7 @@ check_block(BLOCKNUM blocknum, int64_t UU(blocksize), int64_t UU(address), void
{
int r = 0;
int failure = 0;
struct check_block_table_extra *cbte = extra;
struct check_block_table_extra *cbte = cast_to_typeof(cbte) extra;
int fd = cbte->fd;
FT ft = cbte->h;
......@@ -211,7 +211,7 @@ check_block(BLOCKNUM blocknum, int64_t UU(blocksize), int64_t UU(address), void
}
// Allocate the node.
FTNODE node = toku_xmalloc(sizeof(*node));
FTNODE XMALLOC(node);
initialize_ftnode(node, blocknum);
......@@ -328,7 +328,7 @@ check_block_table(int fd, BLOCK_TABLE bt, struct ft *h)
{
int64_t num_blocks = toku_block_get_blocks_in_use_unlocked(bt);
printf("Starting verification of checkpoint containing");
printf(" %"PRId64" blocks.\n", num_blocks);
printf(" %" PRId64 " blocks.\n", num_blocks);
fflush(stdout);
struct check_block_table_extra extra = { .fd = fd,
......@@ -349,8 +349,8 @@ check_block_table(int fd, BLOCK_TABLE bt, struct ft *h)
assert(extra.blocks_done == extra.total_blocks);
printf("Finished verification. ");
printf(" %"PRId64" blocks checked,", extra.blocks_done);
printf(" %"PRId64" bad block(s) detected\n", extra.blocks_failed);
printf(" %" PRId64 " blocks checked,", extra.blocks_done);
printf(" %" PRId64 " bad block(s) detected\n", extra.blocks_failed);
fflush(stdout);
}
......@@ -390,9 +390,9 @@ main(int argc, char *argv[])
dictfname = argv[1];
outfname = argv[2];
if (argc == 4) {
errno = 0;
set_errno(0);
pct = strtod(argv[3], NULL);
assert_zero(errno);
assert_zero(get_maybe_error_errno());
assert(pct > 0.0 && pct <= 100.0);
}
......
......@@ -74,7 +74,7 @@ int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2le
int comparelen = key1len<key2len ? key1len : key2len;
const unsigned char *k1;
const unsigned char *k2;
for (k1=key1, k2=key2;
for (k1 = cast_to_typeof(k1) key1, k2 = cast_to_typeof(k2) key2;
comparelen>4;
k1+=4, k2+=4, comparelen-=4) {
{ int v1=k1[0], v2=k2[0]; if (v1!=v2) return v1-v2; }
......
......@@ -72,7 +72,7 @@ static void ksignal (KIBBUTZ k) {
// to avoid deadlocks in flusher threads.
//
static void *work_on_kibbutz (void *kidv) {
struct kid *kid = kidv;
struct kid *kid = cast_to_typeof(kid) kidv;
KIBBUTZ k = kid->k;
klock(k);
while (1) {
......
......@@ -27,9 +27,9 @@ struct le_cursor {
int
toku_le_cursor_create(LE_CURSOR *le_cursor_result, FT_HANDLE ft_handle, TOKUTXN txn) {
int result = 0;
LE_CURSOR le_cursor = (LE_CURSOR) toku_malloc(sizeof (struct le_cursor));
LE_CURSOR MALLOC(le_cursor);
if (le_cursor == NULL) {
result = errno;
result = get_error_errno();
}
else {
result = toku_ft_cursor(ft_handle, &le_cursor->ft_cursor, txn, false, false);
......
......@@ -29,7 +29,9 @@ struct roll_entry;
static inline int toku_copy_BYTESTRING(BYTESTRING *target, BYTESTRING val) {
target->len = val.len;
target->data = (char *) toku_memdup(val.data, (size_t)val.len);
if (target->data==0) return errno;
if (target->data==0) {
return get_error_errno();
}
return 0;
}
static inline void toku_free_TXNID(TXNID txnid __attribute__((__unused__))) {}
......
......@@ -35,7 +35,7 @@ void toku_logcursor_print(TOKULOGCURSOR lc) {
printf(" n_logfiles = %d\n", lc->n_logfiles);
printf(" cur_logfiles_index = %d\n", lc->cur_logfiles_index);
printf(" cur_fp = %p\n", lc->cur_fp);
printf(" cur_lsn = %"PRIu64"\n", lc->cur_lsn.lsn);
printf(" cur_lsn = %" PRIu64 "\n", lc->cur_lsn.lsn);
printf(" last_direction = %d\n", (int) lc->last_direction);
}
......@@ -81,7 +81,7 @@ static int lc_open_logfile(TOKULOGCURSOR lc, int index) {
return DB_NOTFOUND;
// debug printf("%s:%d %s %p %u\n", __FUNCTION__, __LINE__, lc->logfiles[index], lc->buffer, (unsigned) lc->buffer_size);
#if !TOKU_WINDOWS //Windows reads logs fastest if we use default settings (not use setvbuf to change buffering)
r = setvbuf(lc->cur_fp, lc->buffer, _IOFBF, lc->buffer_size);
r = setvbuf(lc->cur_fp, (char *) lc->buffer, _IOFBF, lc->buffer_size);
assert(r == 0);
#endif
// position fp past header, ignore 0 length file (t:2384)
......@@ -104,7 +104,7 @@ static int lc_check_lsn(TOKULOGCURSOR lc, int dir) {
if (((dir == LC_FORWARD) && ( lsn.lsn != lc->cur_lsn.lsn + 1 )) ||
((dir == LC_BACKWARD) && ( lsn.lsn != lc->cur_lsn.lsn - 1 ))) {
// int index = lc->cur_logfiles_index;
// fprintf(stderr, "Bad LSN: %d %s direction = %d, lsn.lsn = %"PRIu64", cur_lsn.lsn=%"PRIu64"\n",
// fprintf(stderr, "Bad LSN: %d %s direction = %d, lsn.lsn = %" PRIu64 ", cur_lsn.lsn=%" PRIu64 "\n",
// index, lc->logfiles[index], dir, lsn.lsn, lc->cur_lsn.lsn);
if (tokudb_recovery_trace)
printf("DB_RUNRECOVERY: %s:%d r=%d\n", __FUNCTION__, __LINE__, 0);
......@@ -172,12 +172,12 @@ int toku_logcursor_create_for_file(TOKULOGCURSOR *lc, const char *log_dir, const
TOKULOGCURSOR cursor = *lc;
int fullnamelen = strlen(cursor->logdir) + strlen(log_file) + 3;
char *log_file_fullname = toku_xmalloc(fullnamelen);
char *XMALLOC_N(fullnamelen, log_file_fullname);
sprintf(log_file_fullname, "%s/%s", cursor->logdir, log_file);
cursor->n_logfiles=1;
char **logfiles = toku_xmalloc(sizeof(char**));
char **XMALLOC(logfiles);
cursor->logfiles = logfiles;
cursor->logfiles[0] = log_file_fullname;
*lc = cursor;
......
......@@ -23,7 +23,7 @@ struct toku_logfilemgr {
int toku_logfilemgr_create(TOKULOGFILEMGR *lfm) {
// malloc a logfilemgr
TOKULOGFILEMGR mgr = toku_xmalloc(sizeof(struct toku_logfilemgr));
TOKULOGFILEMGR XMALLOC(mgr);
mgr->first = NULL;
mgr->last = NULL;
mgr->n_entries = 0;
......@@ -63,7 +63,7 @@ int toku_logfilemgr_init(TOKULOGFILEMGR lfm, const char *log_dir, TXNID *last_xi
LSN tmp_lsn = {0};
TXNID last_xid = TXNID_NONE;
for(int i=0;i<n_logfiles;i++){
lf_info = toku_xmalloc(sizeof(struct toku_logfile_info));
XMALLOC(lf_info);
// find the index
// basename is the filename of the i-th logfile
basename = strrchr(logfiles[i], '/') + 1;
......@@ -114,7 +114,7 @@ int toku_logfilemgr_num_logfiles(TOKULOGFILEMGR lfm) {
int toku_logfilemgr_add_logfile_info(TOKULOGFILEMGR lfm, TOKULOGFILEINFO lf_info) {
assert(lfm);
struct lfm_entry *entry = toku_xmalloc(sizeof(struct lfm_entry));
struct lfm_entry *XMALLOC(entry);
entry->lf_info = lf_info;
entry->next = NULL;
if ( lfm->n_entries != 0 )
......@@ -167,7 +167,7 @@ void toku_logfilemgr_print(TOKULOGFILEMGR lfm) {
printf("toku_logfilemgr_print [%p] : %d entries \n", lfm, lfm->n_entries);
struct lfm_entry *entry = lfm->first;
for (int i=0;i<lfm->n_entries;i++) {
printf(" entry %d : index = %"PRId64", maxlsn = %"PRIu64"\n", i, entry->lf_info->index, entry->lf_info->maxlsn.lsn);
printf(" entry %d : index = %" PRId64 ", maxlsn = %" PRIu64 "\n", i, entry->lf_info->index, entry->lf_info->maxlsn.lsn);
entry = entry->next;
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -21,7 +21,7 @@ MEMARENA memarena_create_presized (size_t initial_size) {
result->other_bufs = NULL;
result->size_of_other_bufs = 0;
result->n_other_bufs = 0;
result->buf = toku_malloc(result->buf_size); assert(result->buf);
XMALLOC_N(result->buf_size, result->buf);
return result;
}
......@@ -69,8 +69,7 @@ void* malloc_in_memarena (MEMARENA ma, size_t size) {
size_t new_size = 2*ma->buf_size;
if (new_size<size) new_size=size;
new_size=round_to_page(new_size); // at least size, but round to the next page size
ma->buf = toku_malloc(new_size);
assert(ma->buf);
XMALLOC_N(new_size, ma->buf);
ma->buf_used = 0;
ma->buf_size = new_size;
}
......
......@@ -37,7 +37,7 @@ timespec_compare (toku_timespec_t *a, toku_timespec_t *b) {
static void*
minicron_do (void *pv)
{
struct minicron *p = pv;
struct minicron *p = cast_to_typeof(p) pv;
toku_mutex_lock(&p->mutex);
while (1) {
if (p->do_shutdown) {
......
......@@ -146,7 +146,7 @@ static inline int maybe_resize_array(OMT omt, u_int32_t n) {
if (room<n || omt->capacity/2>=new_size) {
OMTVALUE *XMALLOC_N(new_size, tmp_values);
if (tmp_values==NULL) return errno;
if (tmp_values==NULL) return get_error_errno();
memcpy(tmp_values, omt->i.a.values+omt->i.a.start_idx,
omt->i.a.num_values*sizeof(*tmp_values));
omt->i.a.start_idx = 0;
......@@ -164,7 +164,7 @@ static int omt_convert_to_tree(OMT omt) {
new_size = new_size < 4 ? 4 : new_size;
OMT_NODE XMALLOC_N(new_size, new_nodes);
if (new_nodes==NULL) return errno;
if (new_nodes==NULL) return get_error_errno();
OMTVALUE *values = omt->i.a.values;
OMTVALUE *tmp_values = values + omt->i.a.start_idx;
omt->is_array = FALSE;
......@@ -184,7 +184,7 @@ static int omt_convert_to_array(OMT omt) {
new_size = new_size < 4 ? 4 : new_size;
OMTVALUE *XMALLOC_N(new_size, tmp_values);
if (tmp_values==NULL) return errno;
if (tmp_values==NULL) return get_error_errno();
fill_array_with_subtree_values(omt, tmp_values, omt->i.t.root);
toku_free(omt->i.t.nodes);
omt->is_array = TRUE;
......@@ -788,7 +788,7 @@ struct copy_data_extra {
};
static int copy_data_iter(OMTVALUE v, u_int32_t idx, void *ve) {
struct copy_data_extra *e = ve;
struct copy_data_extra *e = cast_to_typeof(e) ve;
memcpy(e->a[idx], v, e->eltsize);
return 0;
}
......@@ -807,9 +807,9 @@ int toku_omt_clone(OMT *dest, OMT src, u_int32_t eltsize) {
toku_omt_create(dest);
return 0;
}
OMTVALUE *a = toku_xmalloc((sizeof *a) * size);
OMTVALUE *XMALLOC_N(size, a);
for (u_int32_t i = 0; i < size; ++i) {
a[i] = toku_xmalloc(eltsize);
a[i] = cast_to_typeof(a[i]) toku_xmalloc(eltsize);
}
int r = omt_copy_data(a, src, eltsize);
if (r != 0) { goto err; }
......@@ -827,8 +827,8 @@ int toku_omt_clone_pool(OMT *dest, OMT src, u_int32_t eltsize) {
toku_omt_create(dest);
return 0;
}
OMTVALUE *a = toku_xmalloc((sizeof *a) * size);
unsigned char *data = toku_xmalloc(eltsize * size);
OMTVALUE *XMALLOC_N(size, a);
unsigned char *XMALLOC_N(eltsize * size, data);
for (u_int32_t i = 0; i < size; ++i) {
a[i] = &data[eltsize * i];
}
......@@ -860,7 +860,7 @@ int toku_omt_clone_noptr(OMT *dest, OMT src) {
toku_omt_create(dest);
return 0;
}
OMTVALUE *a = toku_xmalloc((sizeof *a) * size);
OMTVALUE *XMALLOC_N(size, a);
if (src->is_array) {
memcpy(a, src->i.a.values + src->i.a.start_idx, size * (sizeof *src->i.a.values));
} else {
......
......@@ -16,13 +16,15 @@
int pqueue_init(pqueue_t **result, size_t n, int which_db, DB *db, ft_compare_func compare, struct error_callback_s *err_callback)
{
pqueue_t *q;
if (!(q = toku_malloc(sizeof(pqueue_t))))
return errno;
pqueue_t *MALLOC(q);
if (!q) {
return get_error_errno();
}
/* Need to allocate n+1 elements since element 0 isn't used. */
if (!(q->d = toku_malloc((n + 1) * sizeof(pqueue_node_t *)))) {
int r = errno;
MALLOC_N(n + 1, q->d);
if (!q->d) {
int r = get_error_errno();
toku_free(q);
return r;
}
......
......@@ -46,7 +46,7 @@ struct queue {
int queue_create (QUEUE *q, u_int64_t weight_limit)
{
QUEUE MALLOC(result);
if (result==NULL) return errno;
if (result==NULL) return get_error_errno();
result->contents_weight = 0;
result->weight_limit = weight_limit;
result->head = NULL;
......@@ -75,7 +75,7 @@ int queue_enq (QUEUE q, void *item, u_int64_t weight, u_int64_t *total_weight_af
// Go ahead and put it in, even if it's too much.
struct qitem *MALLOC(qi);
if (qi==NULL) {
int r = errno;
int r = get_error_errno();
toku_mutex_unlock(&q->mutex);
return r;
}
......
This diff is collapsed.
......@@ -49,8 +49,10 @@ toku_commit_fdelete (FILENUM filenum,
// the locktree from the environment's ltm, but that shouldn't
// be necessary since that happens once this txn commits
// (which is after this function ends, essentially)
FT ft = toku_cachefile_get_userdata(cf);
DICTIONARY_ID dict_id = ft->dict_id;
FT ft;
ft = cast_to_typeof(ft) toku_cachefile_get_userdata(cf);
DICTIONARY_ID dict_id;
dict_id = ft->dict_id;
toku_logger_call_remove_finalize_callback(txn->logger, dict_id);
// bug fix for #4718
......@@ -125,8 +127,10 @@ toku_rollback_fcreate (FILENUM filenum,
// the locktree from the environment's ltm, but that shouldn't
// be necessary since that happens once this txn commits
// (which is after this function ends, essentially)
FT ft = toku_cachefile_get_userdata(cf);
DICTIONARY_ID dict_id = ft->dict_id;
FT ft;
ft = cast_to_typeof(ft) toku_cachefile_get_userdata(cf);
DICTIONARY_ID dict_id;
dict_id = ft->dict_id;
toku_logger_call_remove_finalize_callback(txn->logger, dict_id);
// Mark the cachefile as unlink on close. There are two ways for close
......@@ -145,8 +149,8 @@ done:
}
static int find_ft_from_filenum (OMTVALUE v, void *filenumvp) {
FILENUM *filenump=filenumvp;
FT h = v;
FILENUM *filenump = cast_to_typeof(filenump) filenumvp;
FT h = cast_to_typeof(h) v;
FILENUM thisfnum = toku_cachefile_filenum(h->cf);
if (thisfnum.fileid<filenump->fileid) return -1;
if (thisfnum.fileid>filenump->fileid) return +1;
......@@ -171,10 +175,12 @@ static int do_insertion (enum ft_msg_type type, FILENUM filenum, BYTESTRING key,
}
assert(r==0);
OMTVALUE hv=NULL;
OMTVALUE hv;
hv=NULL;
r = toku_omt_find_zero(txn->open_fts, find_ft_from_filenum, &filenum, &hv, NULL);
assert(r==0);
FT h = hv;
FT h;
h = cast_to_typeof(h) hv;
if (oplsn.lsn != 0) { // if we are executing the recovery algorithm
LSN treelsn = toku_ft_checkpoint_lsn(h);
......@@ -185,19 +191,22 @@ static int do_insertion (enum ft_msg_type type, FILENUM filenum, BYTESTRING key,
}
DBT key_dbt,data_dbt;
XIDS xids = toku_txn_get_xids(txn);
FT_MSG_S ftcmd = { type, ZERO_MSN, xids,
.u.id={(key.len > 0)
? toku_fill_dbt(&key_dbt, key.data, key.len)
: toku_init_dbt(&key_dbt),
data
? toku_fill_dbt(&data_dbt, data->data, data->len)
: toku_init_dbt(&data_dbt) }};
r = toku_ft_root_put_cmd(h, &ftcmd);
if (r == 0 && reset_root_xid_that_created) {
TXNID new_root_xid_that_created = xids_get_outermost_xid(xids);
toku_reset_root_xid_that_created(h, new_root_xid_that_created);
XIDS xids;
xids = toku_txn_get_xids(txn);
{
FT_MSG_S ftcmd = { type, ZERO_MSN, xids,
.u = { .id = { (key.len > 0)
? toku_fill_dbt(&key_dbt, key.data, key.len)
: toku_init_dbt(&key_dbt),
data
? toku_fill_dbt(&data_dbt, data->data, data->len)
: toku_init_dbt(&data_dbt) } } };
r = toku_ft_root_put_cmd(h, &ftcmd);
if (r == 0 && reset_root_xid_that_created) {
TXNID new_root_xid_that_created = xids_get_outermost_xid(xids);
toku_reset_root_xid_that_created(h, new_root_xid_that_created);
}
}
done:
return r;
......@@ -446,7 +455,7 @@ toku_rollback_load (FILENUM UU(old_filenum),
// unlink it if it's there and ignore the error if it's not.
char *fname_in_cwd = toku_cachetable_get_fname_in_cwd(ct, fname_in_env);
r = unlink(fname_in_cwd);
assert(r == 0 || errno == ENOENT);
assert(r == 0 || get_error_errno() == ENOENT);
toku_free(fname_in_cwd);
r = 0;
} else {
......@@ -500,12 +509,12 @@ toku_rollback_dictionary_redirect (FILENUM old_filenum,
CACHEFILE new_cf = NULL;
r = toku_cachefile_of_filenum(txn->logger->ct, new_filenum, &new_cf);
assert(r == 0);
FT new_h = toku_cachefile_get_userdata(new_cf);
FT new_h = cast_to_typeof(new_h) toku_cachefile_get_userdata(new_cf);
CACHEFILE old_cf = NULL;
r = toku_cachefile_of_filenum(txn->logger->ct, old_filenum, &old_cf);
assert(r == 0);
FT old_h = toku_cachefile_get_userdata(old_cf);
FT old_h = cast_to_typeof(old_h) toku_cachefile_get_userdata(old_cf);
//Redirect back from new to old.
r = toku_dictionary_redirect_abort(old_h, new_h, txn);
......@@ -541,10 +550,12 @@ toku_rollback_change_fdescriptor(FILENUM filenum,
// noted it,
assert(r == 0);
OMTVALUE ftv = NULL;
OMTVALUE ftv;
ftv = NULL;
r = toku_omt_find_zero(txn->open_fts, find_ft_from_filenum, &filenum, &ftv, NULL);
assert(r == 0);
FT ft = ftv;
FT ft;
ft = cast_to_typeof(ft) ftv;
DESCRIPTOR_S d;
toku_fill_dbt(&d.dbt, old_descriptor.data, old_descriptor.len);
......
......@@ -42,9 +42,9 @@ int toku_abort_rollback_item (TOKUTXN txn, struct roll_entry *item, LSN lsn) {
static int
note_ft_used_in_txns_parent(OMTVALUE ftv, u_int32_t UU(index), void *txnv) {
TOKUTXN child = txnv;
TOKUTXN child = cast_to_typeof(child) txnv;
TOKUTXN parent = child->parent;
FT ft = ftv;
FT ft = cast_to_typeof(ft) ftv;
toku_txn_maybe_note_ft(parent, ft);
if (ft->txnid_that_created_or_locked_when_empty == toku_txn_get_txnid(child)) {
//Pass magic "no rollback needed" flag to parent.
......
......@@ -28,8 +28,8 @@ void toku_rollback_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM logname
void *rollback_v, void** UU(disk_data), void *extraargs, PAIR_ATTR size, PAIR_ATTR* new_size,
BOOL write_me, BOOL keep_me, BOOL for_checkpoint, BOOL UU(is_clone)) {
int r;
ROLLBACK_LOG_NODE log = rollback_v;
FT h = extraargs;
ROLLBACK_LOG_NODE log = cast_to_typeof(log) rollback_v;
FT h = cast_to_typeof(h) extraargs;
assert(log->blocknum.b==logname.b);
if (write_me && !h->panic) {
......@@ -58,7 +58,7 @@ void toku_rollback_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM logname
int toku_rollback_fetch_callback (CACHEFILE cachefile, int fd, BLOCKNUM logname, u_int32_t fullhash,
void **rollback_pv, void** UU(disk_data), PAIR_ATTR *sizep, int * UU(dirtyp), void *extraargs) {
int r;
FT h = extraargs;
FT h = cast_to_typeof(h) extraargs;
assert(h->cf == cachefile);
ROLLBACK_LOG_NODE *result = (ROLLBACK_LOG_NODE*)rollback_pv;
......
......@@ -8,7 +8,7 @@
#include "rollback-ct-callbacks.h"
static void rollback_unpin_remove_callback(CACHEKEY* cachekey, BOOL for_checkpoint, void* extra) {
FT h = extra;
FT h = cast_to_typeof(h) extra;
toku_free_blocknum(
h->blocktable,
cachekey,
......@@ -21,7 +21,7 @@ static void rollback_unpin_remove_callback(CACHEKEY* cachekey, BOOL for_checkpoi
void toku_rollback_log_unpin_and_remove(TOKUTXN txn, ROLLBACK_LOG_NODE log) {
int r;
CACHEFILE cf = txn->logger->rollback_cachefile;
FT h = toku_cachefile_get_userdata(cf);
FT h = cast_to_typeof(h) toku_cachefile_get_userdata(cf);
r = toku_cachetable_unpin_and_remove (cf, log->blocknum, rollback_unpin_remove_callback, h);
assert(r == 0);
}
......@@ -73,7 +73,7 @@ static void rollback_log_create (TOKUTXN txn, BLOCKNUM previous, uint32_t previo
int r;
CACHEFILE cf = txn->logger->rollback_cachefile;
FT h = toku_cachefile_get_userdata(cf);
FT h = cast_to_typeof(h) toku_cachefile_get_userdata(cf);
log->layout_version = FT_LAYOUT_VERSION;
log->layout_version_original = FT_LAYOUT_VERSION;
......@@ -130,8 +130,8 @@ void toku_maybe_spill_rollbacks(TOKUTXN txn, ROLLBACK_LOG_NODE log) {
}
static int find_filenum (OMTVALUE v, void *hv) {
FT h = v;
FT hfind = hv;
FT h = cast_to_typeof(h) v;
FT hfind = cast_to_typeof(hfind) hv;
FILENUM fnum = toku_cachefile_filenum(h->cf);
FILENUM fnumfind = toku_cachefile_filenum(hfind->cf);
if (fnum.fileid<fnumfind.fileid) return -1;
......@@ -176,7 +176,7 @@ void toku_maybe_prefetch_previous_rollback_log(TOKUTXN txn, ROLLBACK_LOG_NODE lo
if (name.b != ROLLBACK_NONE.b) {
uint32_t hash = log->previous_hash;
CACHEFILE cf = txn->logger->rollback_cachefile;
FT h = toku_cachefile_get_userdata(cf);
FT h = cast_to_typeof(h) toku_cachefile_get_userdata(cf);
BOOL doing_prefetch = FALSE;
r = toku_cachefile_prefetch(cf, name, hash,
get_write_callbacks_for_rollback_log(h),
......@@ -199,7 +199,7 @@ void toku_rollback_verify_contents(ROLLBACK_LOG_NODE log,
void toku_get_and_pin_rollback_log(TOKUTXN txn, BLOCKNUM blocknum, uint32_t hash, ROLLBACK_LOG_NODE *log) {
void * value;
CACHEFILE cf = txn->logger->rollback_cachefile;
FT h = toku_cachefile_get_userdata(cf);
FT h = cast_to_typeof(h) toku_cachefile_get_userdata(cf);
int r = toku_cachetable_get_and_pin(cf, blocknum, hash,
&value, NULL,
get_write_callbacks_for_rollback_log(h),
......@@ -210,7 +210,7 @@ void toku_get_and_pin_rollback_log(TOKUTXN txn, BLOCKNUM blocknum, uint32_t hash
h
);
assert(r == 0);
ROLLBACK_LOG_NODE pinned_log = value;
ROLLBACK_LOG_NODE pinned_log = cast_to_typeof(pinned_log) value;
assert(pinned_log->blocknum.b == blocknum.b);
*log = pinned_log;
}
......
......@@ -21,7 +21,7 @@ static int
merge_c(void *vdest, void *va, int an, void *vb, int bn, int width,
void *extra, int (*cmp)(void *, const void *, const void *))
{
char *dest = vdest, *a = va, *b = vb;
char *dest = cast_to_typeof(dest) vdest, *a = cast_to_typeof(a) va, *b = cast_to_typeof(b) vb;
while (an > 0 && bn > 0) {
if (cmp(extra, a, b) < 0) {
memcpy(dest, a, width);
......@@ -47,7 +47,7 @@ binsearch(void *key, void *va, int n, int abefore, int width,
if (n == 0) {
return abefore;
}
char *a = va;
char *a = cast_to_typeof(a) va;
int mid = n / 2;
void *akey = &a[mid * width];
int c = cmp(extra, key, akey);
......@@ -79,7 +79,7 @@ merge(void *vdest, void *va, int an, void *vb, int bn, int width,
return merge_c(vdest, va, an, vb, bn, width, extra, cmp);
}
char *dest = vdest, *a = va, *b = vb;
char *dest = cast_to_typeof(dest) vdest, *a = cast_to_typeof(a) va, *b = cast_to_typeof(b) vb;
if (an < bn) {
char *tmp1 = a; a = b; b = tmp1;
int tmp2 = an; an = bn; bn = tmp2;
......@@ -99,16 +99,16 @@ merge(void *vdest, void *va, int an, void *vb, int bn, int width,
static inline void
swap(void *va, void *vb, int width)
{
u_int64_t *ia = va, *ib = vb, it;
while ((unsigned int) width >= sizeof(u_int64_t)) {
uint64_t *ia = cast_to_typeof(ia) va, *ib = cast_to_typeof(ib) vb, it;
while ((unsigned int) width >= sizeof(uint64_t)) {
it = *ia;
*ia = *ib;
*ib = it;
width -= sizeof(u_int64_t);
width -= sizeof(uint64_t);
ia++;
ib++;
}
unsigned char *ca = (void *) ia, *cb = (void *) ib, ct;
unsigned char *ca = cast_to_typeof(ca) ia, *cb = cast_to_typeof(ca) ib, ct;
while (width > 0) {
ct = *ca;
*ca = *cb;
......@@ -124,7 +124,7 @@ quicksort_r(void *va, int n, int width,
void *extra, int (*cmp)(void *, const void *, const void *))
{
if (n <= 1) { return 0; }
unsigned char *a = va;
unsigned char *a = cast_to_typeof(a) va;
unsigned char *lo = a;
unsigned char *pivot = &a[(n / 2) * width];
unsigned char *hi = &a[(n - 1) * width];
......@@ -172,7 +172,7 @@ mergesort_r(void *va, int n, int width,
if (n < 10000) {
return quicksort_r(va, n, width, extra, cmp);
}
unsigned char *a = va;
unsigned char *a = cast_to_typeof(a) va;
int mid = n / 2;
int r1 = cilk_spawn mergesort_r(a, mid, width, extra, cmp);
int r2 = mergesort_r(&a[mid * width], n - mid, width, extra, cmp);
......
......@@ -282,7 +282,7 @@ decompress_sub_block(void *compress_ptr, u_int32_t compress_size, void *uncompre
result = EINVAL;
} else {
// decompress
toku_decompress(uncompress_ptr, uncompress_size, compress_ptr, compress_size);
toku_decompress((Bytef *) uncompress_ptr, uncompress_size, (Bytef *) compress_ptr, compress_size);
}
return result;
}
......
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE DONT_DEPRECATE_ERRNO)
if(BUILD_TESTING)
## get a list of the sources in this directory
......
......@@ -16,7 +16,8 @@ const double USECS_PER_SEC = 1000000.0;
static int
long_key_cmp(DB *UU(e), const DBT *a, const DBT *b)
{
const long *x = a->data, *y = b->data;
const long *x = cast_to_typeof(x) a->data;
const long *y = cast_to_typeof(y) b->data;
return (*x > *y) - (*x < *y);
}
......@@ -28,10 +29,10 @@ run_test(unsigned long eltsize, unsigned long nodesize, unsigned long repeat)
char *vals[1024];
for (int i = 0; i < 1024; ++i) {
keys[i] = rand();
vals[i] = toku_xmalloc(eltsize - (sizeof keys[i]));
XMALLOC_N(eltsize - (sizeof keys[i]), vals[i]);
unsigned int j = 0;
for (; j < eltsize - (sizeof keys[i]) - sizeof(int); j += sizeof(int)) {
int *p = (void *) &((char *) vals[i])[j];
int *p = cast_to_typeof(p) &((char *) vals[i])[j];
*p = rand();
}
for (; j < eltsize - (sizeof keys[i]); ++j) {
......
......@@ -50,7 +50,7 @@ flush (
{
// printf("f");
assert(size.size== item_size);
int *v = value;
int *v = cast_to_typeof(v) value;
if (*v!=expect_value) printf("got %d expect %d\n", *v, expect_value);
assert(*v==expect_value);
(void)__sync_fetch_and_add(&n_flush, 1);
......@@ -93,7 +93,7 @@ do_update (void *UU(ignore))
//printf("g");
assert(r==0);
assert(size==sizeof(int));
int *v = vv;
int *v = cast_to_typeof(v) vv;
assert(*v==42);
*v = 43;
//printf("[%d]43\n", i);
......@@ -127,7 +127,7 @@ static void checkpoint_pending(void) {
int r;
r = toku_create_cachetable(&ct, test_limit*sizeof(int), ZERO_LSN, NULL_LOGGER); assert(r == 0);
char fname1[] = __SRCFILE__ "test1.dat";
r = unlink(fname1); if (r!=0) CKERR2(errno, ENOENT);
r = unlink(fname1); if (r!=0) CKERR2(get_error_errno(), ENOENT);
r = toku_cachetable_openf(&cf, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
toku_cachefile_set_userdata(cf, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
dummy_pin_unpin, dummy_pin_unpin);
......
......@@ -41,7 +41,7 @@ flush (CACHEFILE f __attribute__((__unused__)),
BOOL c __attribute__((__unused__)),
BOOL UU(is_clone)
) {
PAIR_ATTR *expect = e;
PAIR_ATTR *expect = cast_to_typeof(expect) e;
if (!keep) {
toku_mutex_lock(&attr_mutex); // purpose is to make this function single-threaded
expect->size -= s.size;
......
......@@ -23,7 +23,7 @@ flush (CACHEFILE f __attribute__((__unused__)),
) {
assert(flush_may_occur);
if (!keep) {
int* foo = v;
int* foo = cast_to_typeof(foo) v;
assert(*foo == 3);
toku_free(v);
}
......@@ -41,7 +41,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
int* foo = toku_malloc(sizeof(int));
int* XMALLOC(foo);
*value = foo;
*sizep = make_pair_attr(4);
*foo = 4;
......@@ -74,7 +74,7 @@ pe_callback (
{
*bytes_freed = make_pair_attr(bytes_to_free.size-1);
expected_bytes_to_free--;
int* foo = ftnode_pv;
int* foo = cast_to_typeof(foo) ftnode_pv;
int blah = *foo;
*foo = blah-1;
return 0;
......
......@@ -41,7 +41,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
int* foo = toku_malloc(sizeof(int));
int* XMALLOC(foo);
*value = foo;
*sizep = make_pair_attr(4);
*foo = 4;
......@@ -88,7 +88,7 @@ pe_callback (
*bytes_freed = make_pair_attr(bytes_to_free.size-1);
if (verbose) printf("calling pe_callback\n");
expected_bytes_to_free--;
int* foo = ftnode_pv;
int* foo = cast_to_typeof(foo) ftnode_pv;
int blah = *foo;
*foo = blah-1;
return 0;
......
......@@ -110,7 +110,7 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
gettimeofday(&tend, NULL);
assert(tdelta_usec(&tend, &tstart) >= 2000000);
if (verbose)printf("time %"PRIu64" \n", tdelta_usec(&tend, &tstart));
if (verbose)printf("time %" PRIu64 " \n", tdelta_usec(&tend, &tstart));
toku_cachetable_verify(ct);
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
......
......@@ -137,7 +137,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
gettimeofday(&tend, NULL);
assert(tdelta_usec(&tend, &tstart) >= 2000000);
if (verbose) printf("time %"PRIu64" \n", tdelta_usec(&tend, &tstart));
if (verbose) printf("time %" PRIu64 " \n", tdelta_usec(&tend, &tstart));
toku_cachetable_verify(ct);
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
......
......@@ -12,7 +12,7 @@ BOOL foo;
//
static void kibbutz_work(void *fe_v)
{
CACHEFILE f1 = fe_v;
CACHEFILE f1 = cast_to_typeof(f1) fe_v;
sleep(2);
foo = TRUE;
// note that we make the size 16 to induce an eviction
......
......@@ -34,7 +34,7 @@ clone_callback(
)
{
new_attr->is_valid = FALSE;
int64_t* data_val = toku_xmalloc(sizeof(int64_t));
int64_t* XMALLOC(data_val);
*data_val = *(int64_t *)value_data;
*cloned_value_data = data_val;
}
......@@ -83,7 +83,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
size_t data_index = (size_t)k.b;
assert(data[data_index] != INT64_MAX);
int64_t* data_val = toku_malloc(sizeof(int64_t));
int64_t* XMALLOC(data_val);
usleep(10);
*data_val = data[data_index];
*value = data_val;
......@@ -306,17 +306,17 @@ dummy_int_checkpoint_userdata(CACHEFILE UU(cf), int UU(n), void* UU(extra)) {
static void sum_vals(void) {
int64_t sum = 0;
for (int i = 0; i < NUM_ELEMENTS; i++) {
//printf("actual: i %d val %"PRId64" \n", i, data[i]);
//printf("actual: i %d val %" PRId64 " \n", i, data[i]);
sum += data[i];
}
if (verbose) printf("actual sum %"PRId64" \n", sum);
if (verbose) printf("actual sum %" PRId64 " \n", sum);
assert(sum == 0);
sum = 0;
for (int i = 0; i < NUM_ELEMENTS; i++) {
//printf("checkpointed: i %d val %"PRId64" \n", i, checkpointed_data[i]);
//printf("checkpointed: i %d val %" PRId64 " \n", i, checkpointed_data[i]);
sum += checkpointed_data[i];
}
if (verbose) printf("checkpointed sum %"PRId64" \n", sum);
if (verbose) printf("checkpointed sum %" PRId64 " \n", sum);
assert(sum == 0);
}
......
......@@ -31,7 +31,7 @@ flush (CACHEFILE f __attribute__((__unused__)),
flush_calls++;
if (keep == FALSE) {
flush_evict_calls++;
if (verbose) printf("%s:%d flush %"PRId64"\n", __FUNCTION__, __LINE__, k.b);
if (verbose) printf("%s:%d flush %" PRId64 "\n", __FUNCTION__, __LINE__, k.b);
evicted_keys |= 1 << k.b;
}
}
......@@ -51,7 +51,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
) {
fetch_calls++;
if (verbose) printf("%s:%d %"PRId64"\n", __FUNCTION__, __LINE__, k.b);
if (verbose) printf("%s:%d %" PRId64 "\n", __FUNCTION__, __LINE__, k.b);
*value = 0;
*sizep = make_pair_attr(1);
......
......@@ -37,7 +37,7 @@ clone_callback(
)
{
new_attr->is_valid = FALSE;
int64_t* data_val = toku_xmalloc(sizeof(int64_t));
int64_t* XMALLOC(data_val);
*data_val = *(int64_t *)value_data;
*cloned_value_data = data_val;
*new_attr = make_pair_attr(8);
......@@ -88,7 +88,7 @@ fetch (CACHEFILE f __attribute__((__unused__)),
// the block is not supposed to be in the cachetable
assert(data[data_index] != INT64_MAX);
int64_t* data_val = toku_malloc(sizeof(int64_t));
int64_t* XMALLOC(data_val);
usleep(10);
*data_val = data[data_index];
*value = data_val;
......@@ -214,7 +214,7 @@ static void remove_data(CACHEKEY* cachekey, BOOL for_checkpoint, void* UU(extra)
static void get_data(CACHEKEY* cachekey, u_int32_t* fullhash, void* extra) {
int* key = extra;
int* key = cast_to_typeof(key) extra;
cachekey->b = *key;
*fullhash = toku_cachetable_hash(f1, *cachekey);
data[*key] = INT64_MAX - 1;
......@@ -313,7 +313,7 @@ static void merge_and_split_child(
// now do a split
CACHEKEY new_key;
u_int32_t new_fullhash;
int64_t* data_val = toku_malloc(sizeof(int64_t));
int64_t* XMALLOC(data_val);
r = toku_cachetable_put_with_dep_pairs(
f1,
get_data,
......@@ -435,21 +435,21 @@ dummy_int_checkpoint_userdata(CACHEFILE UU(cf), int UU(n), void* UU(extra)) {
static void sum_vals(void) {
int64_t sum = 0;
for (int i = 0; i < NUM_ELEMENTS; i++) {
//printf("actual: i %d val %"PRId64" \n", i, data[i]);
//printf("actual: i %d val %" PRId64 " \n", i, data[i]);
if (data[i] != INT64_MAX) {
sum += data[i];
}
}
if (verbose) printf("actual sum %"PRId64" \n", sum);
if (verbose) printf("actual sum %" PRId64 " \n", sum);
assert(sum == 0);
sum = 0;
for (int i = 0; i < NUM_ELEMENTS; i++) {
//printf("checkpointed: i %d val %"PRId64" \n", i, checkpointed_data[i]);
//printf("checkpointed: i %d val %" PRId64 " \n", i, checkpointed_data[i]);
if (checkpointed_data[i] != INT64_MAX) {
sum += checkpointed_data[i];
}
}
if (verbose) printf("checkpointed sum %"PRId64" \n", sum);
if (verbose) printf("checkpointed sum %" PRId64 " \n", sum);
assert(sum == 0);
}
......
......@@ -75,7 +75,7 @@ rw_event_destroy (struct rw_event *rwe) {
static void *
test_writer_priority_thread (void *arg) {
struct rw_event *rwe = arg;
struct rw_event *rwe = cast_to_typeof(rwe) arg;
toku_mutex_lock(&rwe->mutex);
rwlock_write_lock(&rwe->the_rwlock, &rwe->mutex);
......@@ -135,7 +135,7 @@ test_writer_priority (void) {
static void *
test_single_writer_thread (void *arg) {
struct rw_event *rwe = arg;
struct rw_event *rwe = cast_to_typeof(rwe) arg;
toku_mutex_lock(&rwe->mutex);
rwlock_write_lock(&rwe->the_rwlock, &rwe->mutex);
......
......@@ -47,7 +47,7 @@ static int true_def_pf_callback(void* UU(ftnode_pv), void* UU(dd), void* UU(read
static void kibbutz_work(void *fe_v)
{
CACHEFILE f1 = fe_v;
CACHEFILE f1 = cast_to_typeof(f1) fe_v;
sleep(2);
foo = TRUE;
int r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
......
......@@ -40,7 +40,7 @@ flush (CACHEFILE f __attribute__((__unused__)),
static void kibbutz_work(void *fe_v)
{
CACHEFILE f1 = fe_v;
CACHEFILE f1 = cast_to_typeof(f1) fe_v;
sleep(2);
foo = TRUE;
int r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
......
......@@ -60,11 +60,11 @@ static const int test_object_size = 1;
struct item {
CACHEKEY key;
char *something;
const char *something;
};
static volatile int expect_n_flushes=0;
static volatile CACHEKEY flushes[100];
static CACHEKEY flushes[100];
static void expect_init(void) {
test_mutex_lock();
......@@ -101,7 +101,7 @@ static void flush (CACHEFILE f,
BOOL for_checkpoint __attribute__((__unused__)),
BOOL UU(is_clone)
) {
struct item *it = value;
struct item *it = cast_to_typeof(it) value;
int i;
if (keep_me) return;
......@@ -302,7 +302,7 @@ static void flush_n (CACHEFILE f __attribute__((__unused__)), int UU(fd), CACHEK
BOOL for_checkpoint __attribute__ ((__unused__)),
BOOL UU(is_clone)
) {
int *v = value;
int *v = cast_to_typeof(v) value;
assert(*v==0);
}
static int fetch_n (CACHEFILE f __attribute__((__unused__)), int UU(fd), CACHEKEY key __attribute__((__unused__)),
......@@ -487,7 +487,7 @@ static void test_dirty(void) {
r = toku_create_cachetable(&t, 4, ZERO_LSN, NULL_LOGGER);
assert(r == 0);
char *fname = __SRCFILE__ "test.dat";
const char *fname = __SRCFILE__ "test.dat";
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r == 0);
......@@ -620,7 +620,7 @@ static void test_size_resize(void) {
r = toku_create_cachetable(&t, n*size, ZERO_LSN, NULL_LOGGER);
assert(r == 0);
char *fname = __SRCFILE__ "test.dat";
const char *fname = __SRCFILE__ "test.dat";
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r == 0);
......@@ -678,7 +678,7 @@ static void test_size_flush(void) {
r = toku_create_cachetable(&t, n*size, ZERO_LSN, NULL_LOGGER);
assert(r == 0);
char *fname = __SRCFILE__ "test.dat";
const char *fname = __SRCFILE__ "test.dat";
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r == 0);
......
......@@ -109,7 +109,7 @@ static void flush_forchain (CACHEFILE f __attribute__((__unused__)),
BOOL UU(is_clone)
) {
if (keep_me) return;
int *v = value;
int *v = cast_to_typeof(v) value;
//toku_cachetable_print_state(ct);
//printf("Flush %lld %d\n", key, (int)value);
assert((long)v==(long)key.b);
......
......@@ -26,7 +26,10 @@ static void test1 (size_t chars_per_file, size_t bytes_per_read) {
for (size_t j=0; j<chars_per_file; j++) {
unsigned char c = (i+j)%256;
int r = toku_os_write(fds[i], &c, 1);
if (r!=0) printf("fds[%d]=%d r=%d errno=%d (%s)\n", i, fds[i], r, errno, strerror(errno));
if (r!=0) {
int er = get_maybe_error_errno();
printf("fds[%d]=%d r=%d errno=%d (%s)\n", i, fds[i], r, er, strerror(er));
}
assert(r==0);
}
{
......
......@@ -5,7 +5,6 @@
#include "test.h"
int verbose;
static void
test_fifo_create (void) {
......@@ -36,13 +35,13 @@ test_fifo_enq (int n) {
// this was a function but icc cant handle it
#define buildkey(len) { \
thekeylen = len+1; \
thekey = toku_realloc(thekey, thekeylen); \
XREALLOC_N(thekeylen, thekey); \
memset(thekey, len, thekeylen); \
}
#define buildval(len) { \
thevallen = len+2; \
theval = toku_realloc(theval, thevallen); \
XREALLOC_N(thevallen, theval); \
memset(theval, ~len, thevallen); \
}
......@@ -66,7 +65,7 @@ test_fifo_enq (int n) {
int i = 0;
FIFO_ITERATE(f, key, keylen, val, vallen, type, msn, xids, UU(is_fresh), {
if (verbose) printf("checkit %d %d %"PRIu64"\n", i, type, msn.msn);
if (verbose) printf("checkit %d %d %" PRIu64 "\n", i, type, msn.msn);
assert(msn.msn == startmsn.msn + i);
buildkey(i);
buildval(i);
......
......@@ -20,7 +20,7 @@ static void
test_prefetch_read(int fd, FT_HANDLE UU(brt), FT brt_h) {
int r;
brt_h->compare_fun = int64_key_cmp;
FT_CURSOR cursor = toku_malloc(sizeof *cursor);
FT_CURSOR XMALLOC(cursor);
FTNODE dn = NULL;
PAIR_ATTR attr;
......@@ -167,7 +167,7 @@ static void
test_subset_read(int fd, FT_HANDLE UU(brt), FT brt_h) {
int r;
brt_h->compare_fun = int64_key_cmp;
FT_CURSOR cursor = toku_malloc(sizeof *cursor);
FT_CURSOR XMALLOC(cursor);
FTNODE dn = NULL;
FTNODE_DISK_DATA ndd = NULL;
PAIR_ATTR attr;
......
......@@ -18,13 +18,15 @@ enum ftnode_verify_type {
static int
string_key_cmp(DB *UU(e), const DBT *a, const DBT *b)
{
char *s = a->data, *t = b->data;
char *s = cast_to_typeof(s) a->data;
char *t = cast_to_typeof(t) b->data;
return strcmp(s, t);
}
static int omt_cmp(OMTVALUE p, void *q)
{
LEAFENTRY a = p, b = q;
LEAFENTRY a = cast_to_typeof(a) p;
LEAFENTRY b = cast_to_typeof(b) q;
void *ak, *bk;
u_int32_t al, bl;
ak = le_key_and_len(a, &al);
......@@ -40,9 +42,9 @@ static int omt_cmp(OMTVALUE p, void *q)
}
static LEAFENTRY
le_fastmalloc(char *key, int keylen, char *val, int vallen)
le_fastmalloc(const char *key, int keylen, const char *val, int vallen)
{
LEAFENTRY r = toku_malloc(sizeof(r->type) + sizeof(r->keylen) + sizeof(r->u.clean.vallen) +
LEAFENTRY r = cast_to_typeof(r) toku_malloc(sizeof(r->type) + sizeof(r->keylen) + sizeof(r->u.clean.vallen) +
keylen + vallen);
resource_assert(r);
r->type = LE_CLEAN;
......@@ -54,7 +56,7 @@ le_fastmalloc(char *key, int keylen, char *val, int vallen)
}
static LEAFENTRY
le_malloc(char *key, char *val)
le_malloc(const char *key, const char *val)
{
int keylen = strlen(key) + 1;
int vallen = strlen(val) + 1;
......
......@@ -15,7 +15,8 @@ const double USECS_PER_SEC = 1000000.0;
static int omt_cmp(OMTVALUE p, void *q)
{
LEAFENTRY a = p, b = q;
LEAFENTRY a = cast_to_typeof(a) p;
LEAFENTRY b = cast_to_typeof(b) q;
void *ak, *bk;
u_int32_t al, bl;
ak = le_key_and_len(a, &al);
......@@ -33,7 +34,7 @@ static int omt_cmp(OMTVALUE p, void *q)
static LEAFENTRY
le_fastmalloc(char *key, int keylen, char *val, int vallen)
{
LEAFENTRY r = toku_malloc(sizeof(r->type) + sizeof(r->keylen) + sizeof(r->u.clean.vallen) +
LEAFENTRY r = cast_to_typeof(r) toku_malloc(sizeof(r->type) + sizeof(r->keylen) + sizeof(r->u.clean.vallen) +
keylen + vallen);
resource_assert(r);
r->type = LE_CLEAN;
......@@ -47,7 +48,8 @@ le_fastmalloc(char *key, int keylen, char *val, int vallen)
static int
long_key_cmp(DB *UU(e), const DBT *a, const DBT *b)
{
const long *x = a->data, *y = b->data;
const long *x = cast_to_typeof(x) a->data;
const long *y = cast_to_typeof(y) b->data;
return (*x > *y) - (*x < *y);
}
......
......@@ -11,7 +11,8 @@
static int omt_int_cmp(OMTVALUE p, void *q)
{
LEAFENTRY a = p, b = q;
LEAFENTRY a = cast_to_typeof(a) p;
LEAFENTRY b = cast_to_typeof(b) q;
void *ak, *bk;
u_int32_t al, bl;
ak = le_key_and_len(a, &al);
......@@ -28,7 +29,8 @@ static int omt_int_cmp(OMTVALUE p, void *q)
static int omt_cmp(OMTVALUE p, void *q)
{
LEAFENTRY a = p, b = q;
LEAFENTRY a = cast_to_typeof(a) p;
LEAFENTRY b = cast_to_typeof(b) q;
void *ak, *bk;
u_int32_t al, bl;
ak = le_key_and_len(a, &al);
......@@ -52,11 +54,11 @@ calc_le_size(int keylen, int vallen) {
}
static LEAFENTRY
le_fastmalloc(struct mempool * mp, char *key, int keylen, char *val, int vallen)
le_fastmalloc(struct mempool * mp, const char *key, int keylen, const char *val, int vallen)
{
LEAFENTRY le;
size_t le_size = calc_le_size(keylen, vallen);
le = toku_mempool_malloc(mp, le_size, 1);
le = cast_to_typeof(le) toku_mempool_malloc(mp, le_size, 1);
resource_assert(le);
le->type = LE_CLEAN;
le->keylen = keylen;
......@@ -67,7 +69,7 @@ le_fastmalloc(struct mempool * mp, char *key, int keylen, char *val, int vallen)
}
static LEAFENTRY
le_malloc(struct mempool * mp, char *key, char *val)
le_malloc(struct mempool * mp, const char *key, const char *val)
{
int keylen = strlen(key) + 1;
int vallen = strlen(val) + 1;
......@@ -82,7 +84,7 @@ struct check_leafentries_struct {
};
static int check_leafentries(OMTVALUE v, u_int32_t UU(i), void *extra) {
struct check_leafentries_struct *e = extra;
struct check_leafentries_struct *e = cast_to_typeof(e) extra;
assert(e->i < e->nelts);
assert(e->cmp(v, e->elts[e->i]) == 0);
e->i++;
......@@ -98,7 +100,8 @@ enum ftnode_verify_type {
static int
string_key_cmp(DB *UU(e), const DBT *a, const DBT *b)
{
char *s = a->data, *t = b->data;
char *s = cast_to_typeof(s) a->data;
char *t = cast_to_typeof(t) b->data;
return strcmp(s, t);
}
......@@ -187,7 +190,7 @@ static void write_sn_to_disk(int fd, FT_HANDLE brt, FTNODE sn, FTNODE_DISK_DATA*
void* cloned_node_v = NULL;
PAIR_ATTR attr;
toku_ftnode_clone_callback(sn, &cloned_node_v, &attr, FALSE, brt->ft);
FTNODE cloned_node = cloned_node_v;
FTNODE cloned_node = cast_to_typeof(cloned_node) cloned_node_v;
r = toku_serialize_ftnode_to(fd, make_blocknum(20), cloned_node, src_ndd, FALSE, brt->ft, 1, 1, FALSE);
assert(r==0);
toku_ftnode_free(&cloned_node);
......@@ -317,7 +320,7 @@ test_serialize_leaf_check_msn(enum ftnode_verify_type bft, BOOL do_clone) {
toku_omt_iterate(BLB_BUFFER(dn, i), check_leafentries, &extra);
u_int32_t keylen;
if (i < npartitions-1) {
assert(strcmp(dn->childkeys[i].data, le_key_and_len(elts[extra.i-1], &keylen))==0);
assert(strcmp((char*)dn->childkeys[i].data, (char*)le_key_and_len(elts[extra.i-1], &keylen))==0);
}
// don't check soft_copy_is_up_to_date or seqinsert
assert(BLB_NBYTESINBUF(dn, i) == (extra.i-last_i)*(KEY_VALUE_OVERHEAD+2+5) + toku_omt_size(BLB_BUFFER(dn, i)));
......@@ -392,7 +395,7 @@ test_serialize_leaf_with_large_pivots(enum ftnode_verify_type bft, BOOL do_clone
BLB_NBYTESINBUF(&sn, i) = leafentry_disksize(le);
if (i < nrows-1) {
u_int32_t keylen;
char *keyp = le_key_and_len(le, &keylen);
char *keyp = cast_to_typeof(keyp) le_key_and_len(le, &keylen);
toku_fill_dbt(&sn.childkeys[i], toku_xmemdup(keyp, keylen), keylen);
}
}
......@@ -1187,7 +1190,7 @@ test_serialize_leaf(enum ftnode_verify_type bft, BOOL do_clone) {
toku_omt_iterate(BLB_BUFFER(dn, i), check_leafentries, &extra);
u_int32_t keylen;
if (i < npartitions-1) {
assert(strcmp(dn->childkeys[i].data, le_key_and_len(elts[extra.i-1], &keylen))==0);
assert(strcmp((char*)dn->childkeys[i].data, (char*)le_key_and_len(elts[extra.i-1], &keylen))==0);
}
// don't check soft_copy_is_up_to_date or seqinsert
assert(BLB_NBYTESINBUF(dn, i) == (extra.i-last_i)*(KEY_VALUE_OVERHEAD+2+5) + toku_omt_size(BLB_BUFFER(dn, i)));
......@@ -1315,7 +1318,7 @@ test_serialize_nonleaf(enum ftnode_verify_type bft, BOOL do_clone) {
assert(dn->layout_version_read_from_disk ==FT_LAYOUT_VERSION);
assert(dn->height == 1);
assert(dn->n_children==2);
assert(strcmp(dn->childkeys[0].data, "hello")==0);
assert(strcmp((char*)dn->childkeys[0].data, "hello")==0);
assert(dn->childkeys[0].size==6);
assert(dn->totalchildkeylens==6);
assert(BP_BLOCKNUM(dn,0).b==30);
......
......@@ -14,7 +14,7 @@ static int
save_data (ITEMLEN UU(keylen), bytevec UU(key), ITEMLEN vallen, bytevec val, void *v, bool lock_only) {
if (lock_only) return 0;
assert(key!=NULL);
void **vp = v;
void **vp = cast_to_typeof(vp) v;
*vp = toku_memdup(val, vallen);
return 0;
}
......@@ -73,7 +73,7 @@ static void test_multiple_ft_cursor_dbts(int n) {
for (i=0; i<n; i++) {
int j;
for (j=i+1; j<n; j++) {
assert(strcmp(ptrs[i],ptrs[j])!=0);
assert(strcmp((char*)ptrs[i],(char*)ptrs[j])!=0);
}
}
......
......@@ -386,14 +386,14 @@ ascending_key_string_checkf (ITEMLEN keylen, bytevec key, ITEMLEN UU(vallen), by
{
if (lock_only) return 0;
if (key!=NULL) {
assert(keylen == 1+strlen(key));
char **prevkeyp = v;
assert(keylen == 1+strlen((char*)key));
char **prevkeyp = cast_to_typeof(prevkeyp) v;
char *prevkey = *prevkeyp;
if (prevkey!=0) {
assert(strcmp(prevkey, key)<0);
assert(strcmp(prevkey, (char*)key)<0);
toku_free(prevkey);
}
*prevkeyp = toku_strdup(key);
*prevkeyp = toku_strdup((char*) key);
}
return 0;
}
......
This diff is collapsed.
......@@ -44,7 +44,7 @@ static void test5 (void) {
if (i%1000==0 && verbose) { printf("r"); fflush(stdout); }
snprintf(key, 100, "key%d", rk);
snprintf(valexpected, 100, "val%d", values[rk]);
struct check_pair pair = {1+strlen(key), key, 1+strlen(valexpected), valexpected, 0};
struct check_pair pair = {(ITEMLEN) (1+strlen(key)), key, (ITEMLEN) (1+strlen(valexpected)), valexpected, 0};
r = toku_ft_lookup(t, toku_fill_dbt(&k, key, 1+strlen(key)), lookup_checkf, &pair);
assert(r==0);
assert(pair.call_count==1);
......
......@@ -63,8 +63,10 @@ static void populate_rowset(struct rowset *rowset, int seq, int nrows) {
for (int i = 0; i < nrows; i++) {
int k = seq * nrows + i;
int v = seq * nrows + i;
DBT key = { .size = sizeof k, .data = &k };
DBT val = { .size = sizeof v, .data = &v };
DBT key;
toku_fill_dbt(&key, &k, sizeof k);
DBT val;
toku_fill_dbt(&val, &v, sizeof v);
add_row(rowset, &key, &val);
}
}
......
......@@ -57,8 +57,10 @@ static void populate_rowset(struct rowset *rowset, int seq, int nrows, int keys[
for (int i = 0; i < nrows; i++) {
int k = keys[i];
int v = seq * nrows + i;
DBT key = { .size = sizeof k, .data = &k };
DBT val = { .size = sizeof v, .data = &v };
DBT key;
toku_fill_dbt(&key, &k, sizeof k);
DBT val;
toku_fill_dbt(&val, &v, sizeof v);
add_row(rowset, &key, &val);
}
}
......@@ -80,7 +82,7 @@ static void test_extractor(int nrows, int nrowsets, BOOL expect_fail, const char
int r;
int nkeys = nrows * nrowsets;
int *keys = toku_malloc(nkeys * sizeof (int)); assert(keys);
int *XMALLOC_N(nkeys, keys);
for (int i = 0; i < nkeys; i++)
keys[i] = ascending_keys ? i : nkeys - i;
if (random_keys)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment