Commit 1db40bfb authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Get rid of some compiler warnings. Addresses #1185.

git-svn-id: file:///svn/tokudb.1131b+1080a+1185@6376 c7de825b-a66e-492c-adef-691d508d4ae1
parent c772ca73
...@@ -675,7 +675,6 @@ static int cachetable_insert_at(CACHEFILE cachefile, u_int32_t fullhash, CACHEKE ...@@ -675,7 +675,6 @@ static int cachetable_insert_at(CACHEFILE cachefile, u_int32_t fullhash, CACHEKE
enum { hash_histogram_max = 100 }; enum { hash_histogram_max = 100 };
static unsigned long long hash_histogram[hash_histogram_max]; static unsigned long long hash_histogram[hash_histogram_max];
void print_hash_histogram (void) __attribute__((__visibility__("default")));
void print_hash_histogram (void) { void print_hash_histogram (void) {
int i; int i;
for (i=0; i<hash_histogram_max; i++) for (i=0; i<hash_histogram_max; i++)
......
...@@ -178,4 +178,7 @@ void toku_cachefile_verify (CACHEFILE cf); ...@@ -178,4 +178,7 @@ void toku_cachefile_verify (CACHEFILE cf);
// Verify the cachetable. Slow. // Verify the cachetable. Slow.
void toku_cachetable_verify (CACHETABLE t); void toku_cachetable_verify (CACHETABLE t);
// Not for use in production, but useful for testing.
void print_hash_histogram (void) __attribute__((__visibility__("default")));
#endif #endif
...@@ -57,7 +57,7 @@ void *toku_realloc(void *, size_t size); ...@@ -57,7 +57,7 @@ void *toku_realloc(void *, size_t size);
#define REALLOC_N(n,v) v = toku_realloc(v, (n)*sizeof(*v)) #define REALLOC_N(n,v) v = toku_realloc(v, (n)*sizeof(*v))
// XMALLOC macros are like MALLOC except they abort if the operatoin fails // XMALLOC macros are like MALLOC except they abort if the operation fails
#define XMALLOC(v) v = toku_xmalloc(sizeof(*v)) #define XMALLOC(v) v = toku_xmalloc(sizeof(*v))
#define XMALLOC_N(n,v) v = toku_malloc((n)*sizeof(*v)) #define XMALLOC_N(n,v) v = toku_malloc((n)*sizeof(*v))
#define XREALLOC_N(n,v) v = toku_realloc(v, (n)*sizeof(*v)) #define XREALLOC_N(n,v) v = toku_realloc(v, (n)*sizeof(*v))
......
...@@ -34,7 +34,7 @@ VISIBILITY=-fvisibility=hidden ...@@ -34,7 +34,7 @@ VISIBILITY=-fvisibility=hidden
endif endif
endif endif
CFLAGS = -Wall $(FORMAT) $(OPTFLAGS) $(GCOV_FLAGS) $(PROF_FLAGS) $(FPICFLAGS) $(SHADOW) $(VISIBILITY) CFLAGS = -Werror -Wall $(FORMAT) $(OPTFLAGS) $(GCOV_FLAGS) $(PROF_FLAGS) $(FPICFLAGS) $(SHADOW) $(VISIBILITY)
ifneq ($(CC),icc) ifneq ($(CC),icc)
CFLAGS += -Wextra -Wcast-align -Wbad-function-cast -Wmissing-noreturn -g3 -ggdb3 CFLAGS += -Wextra -Wcast-align -Wbad-function-cast -Wmissing-noreturn -g3 -ggdb3
else else
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#define RECORDS 2 #define RECORDS 2
void test (int seed) { static void
test (int seed) {
srandom(seed); srandom(seed);
unlink(FNAME); unlink(FNAME);
int i; int i;
......
...@@ -55,19 +55,21 @@ static void test4 (int nodesize, int count, int memcheck) { ...@@ -55,19 +55,21 @@ static void test4 (int nodesize, int count, int memcheck) {
static void brt_blackbox_test (void) { static void brt_blackbox_test (void) {
test4(2048, 1<<14, 1); test4(2048, 1<<14, 1);
return;
if (verbose) printf("test4 slow\n"); if (0) {
test4(2048, 1<<15, 1);
//if (verbose) toku_pma_show_stats(); if (verbose) printf("test4 slow\n");
test4(2048, 1<<15, 1);
test4(1<<15, 1024, 1); //if (verbose) toku_pma_show_stats();
test4(1<<18, 1<<20, 0); test4(1<<15, 1024, 1);
// Once upon a time srandom(8) caused this test to fail. test4(1<<18, 1<<20, 0);
srandom(8); test4(2048, 1<<15, 1);
// Once upon a time srandom(8) caused this test to fail.
srandom(8); test4(2048, 1<<15, 1);
}
} }
int main (int argc , const char *argv[]) { int main (int argc , const char *argv[]) {
......
...@@ -5,14 +5,34 @@ ...@@ -5,14 +5,34 @@
#include "test.h" #include "test.h"
#include "cachetable.h" #include "cachetable.h"
void flush() { static void
flush (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
long s __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
LSN m __attribute__((__unused__)),
BOOL r __attribute__((__unused__))
) {
/* Do nothing */
} }
int fetch() { static int
fetch (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
long *sizep __attribute__((__unused__)),
void *extraargs __attribute__((__unused__)),
LSN *written_lsn __attribute__((__unused__))
) {
return 0; return 0;
} }
void cachetable_count_pinned_test(int n) { static void
cachetable_count_pinned_test (int n) {
const int test_limit = 2*n; const int test_limit = 2*n;
int r; int r;
CACHETABLE ct; CACHETABLE ct;
......
...@@ -5,14 +5,34 @@ ...@@ -5,14 +5,34 @@
#include "test.h" #include "test.h"
#include "cachetable.h" #include "cachetable.h"
void flush() { static void
flush (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
long s __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
LSN m __attribute__((__unused__)),
BOOL r __attribute__((__unused__))
) {
/* Do nothing */
} }
int fetch() { static int
fetch (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
long *sizep __attribute__((__unused__)),
void *extraargs __attribute__((__unused__)),
LSN *written_lsn __attribute__((__unused__))
) {
return 0; return 0;
} }
void cachetable_debug_test(int n) { static void
cachetable_debug_test (int n) {
const int test_limit = n; const int test_limit = n;
int r; int r;
CACHETABLE ct; CACHETABLE ct;
...@@ -57,7 +77,6 @@ void cachetable_debug_test(int n) { ...@@ -57,7 +77,6 @@ void cachetable_debug_test(int n) {
} }
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
extern void print_hash_histogram();
print_hash_histogram(); print_hash_histogram();
r = toku_cachefile_close(&f1, NULL_LOGGER); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER); assert(r == 0 && f1 == 0);
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
#include "test.h" #include "test.h"
#include "cachetable.h" #include "cachetable.h"
void cachetable_fd_test() { static void
cachetable_fd_test (void) {
const int test_limit = 1; const int test_limit = 1;
int r; int r;
CACHETABLE ct; CACHETABLE ct;
......
...@@ -5,14 +5,34 @@ ...@@ -5,14 +5,34 @@
#include "test.h" #include "test.h"
#include "cachetable.h" #include "cachetable.h"
void flush() { static void
flush (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
long s __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
LSN m __attribute__((__unused__)),
BOOL r __attribute__((__unused__))
) {
/* Do nothing */
} }
int fetch() { static int
fetch (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
long *sizep __attribute__((__unused__)),
void *extraargs __attribute__((__unused__)),
LSN *written_lsn __attribute__((__unused__))
) {
return 0; return 0;
} }
void test_cachetable_flush(int n) { static void
test_cachetable_flush (int n) {
const int test_limit = 2*n; const int test_limit = 2*n;
int r; int r;
CACHETABLE ct; CACHETABLE ct;
......
...@@ -5,39 +5,43 @@ ...@@ -5,39 +5,43 @@
#include "test.h" #include "test.h"
#include "cachetable.h" #include "cachetable.h"
void flush(CACHEFILE cf __attribute__((__unused__)), static void
CACHEKEY key __attribute__((__unused__)), flush (CACHEFILE cf __attribute__((__unused__)),
void *v __attribute__((__unused__)), CACHEKEY key __attribute__((__unused__)),
void *extraargs __attribute__((__unused__)), void *v __attribute__((__unused__)),
long size __attribute__((__unused__)), void *extraargs __attribute__((__unused__)),
BOOL write_me __attribute__((__unused__)), long size __attribute__((__unused__)),
BOOL keep_me __attribute__((__unused__)), BOOL write_me __attribute__((__unused__)),
LSN lsn __attribute__((__unused__)), BOOL keep_me __attribute__((__unused__)),
BOOL rename_p __attribute__((__unused__)) LSN lsn __attribute__((__unused__)),
) { BOOL rename_p __attribute__((__unused__))
) {
assert((long) key.b == size); assert((long) key.b == size);
if (!keep_me) free(v); if (!keep_me) free(v);
} }
int fetch(CACHEFILE cf, CACHEKEY key, u_int32_t hash, void **vptr, long *sizep, void *extra, LSN *written_lsn) { static int
fetch (CACHEFILE cf, CACHEKEY key, u_int32_t hash, void **vptr, long *sizep, void *extra, LSN *written_lsn) {
cf = cf; hash = hash; extra = extra; written_lsn = written_lsn; cf = cf; hash = hash; extra = extra; written_lsn = written_lsn;
*sizep = (long) key.b; *sizep = (long) key.b;
*vptr = malloc(*sizep); *vptr = malloc(*sizep);
return 0; return 0;
} }
int fetch_error(CACHEFILE cf __attribute__((__unused__)), static int
CACHEKEY key __attribute__((__unused__)), fetch_error (CACHEFILE cf __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)), CACHEKEY key __attribute__((__unused__)),
void **value __attribute__((__unused__)), u_int32_t fullhash __attribute__((__unused__)),
long *sizep __attribute__((__unused__)), void **value __attribute__((__unused__)),
void*extraargs __attribute__((__unused__)), long *sizep __attribute__((__unused__)),
LSN *written_lsn __attribute__((__unused__)) void*extraargs __attribute__((__unused__)),
) { LSN *written_lsn __attribute__((__unused__))
) {
return -1; return -1;
} }
void cachetable_getandpin_test(int n) { static void
cachetable_getandpin_test (int n) {
const int test_limit = 1024*1024; const int test_limit = 1024*1024;
int r; int r;
CACHETABLE ct; CACHETABLE ct;
......
...@@ -5,14 +5,34 @@ ...@@ -5,14 +5,34 @@
#include "test.h" #include "test.h"
#include "cachetable.h" #include "cachetable.h"
void flush() { static void
flush (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
long s __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
LSN m __attribute__((__unused__)),
BOOL r __attribute__((__unused__))
) {
/* Do nothing */
} }
int fetch() { static int
fetch (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
long *sizep __attribute__((__unused__)),
void *extraargs __attribute__((__unused__)),
LSN *written_lsn __attribute__((__unused__))
) {
return 0; return 0;
} }
void cachetable_put_test(int n) { static void
cachetable_put_test (int n) {
const int test_limit = 2*n; const int test_limit = 2*n;
int r; int r;
CACHETABLE ct; CACHETABLE ct;
......
...@@ -12,7 +12,8 @@ int verbose = 0; ...@@ -12,7 +12,8 @@ int verbose = 0;
// test create and destroy // test create and destroy
void test_create_destroy() { static void
test_create_destroy (void) {
struct ctpair_rwlock the_rwlock, *rwlock = &the_rwlock; struct ctpair_rwlock the_rwlock, *rwlock = &the_rwlock;
ctpair_rwlock_init(rwlock); ctpair_rwlock_init(rwlock);
...@@ -21,7 +22,8 @@ void test_create_destroy() { ...@@ -21,7 +22,8 @@ void test_create_destroy() {
// test read lock and unlock with no writers // test read lock and unlock with no writers
void test_simple_read_lock(int n) { static void
test_simple_read_lock (int n) {
struct ctpair_rwlock the_rwlock, *rwlock = &the_rwlock; struct ctpair_rwlock the_rwlock, *rwlock = &the_rwlock;
ctpair_rwlock_init(rwlock); ctpair_rwlock_init(rwlock);
...@@ -42,7 +44,8 @@ void test_simple_read_lock(int n) { ...@@ -42,7 +44,8 @@ void test_simple_read_lock(int n) {
// test write lock and unlock with no readers // test write lock and unlock with no readers
void test_simple_write_lock() { static void
test_simple_write_lock (void) {
struct ctpair_rwlock the_rwlock, *rwlock = &the_rwlock; struct ctpair_rwlock the_rwlock, *rwlock = &the_rwlock;
ctpair_rwlock_init(rwlock); ctpair_rwlock_init(rwlock);
...@@ -61,18 +64,21 @@ struct rw_event { ...@@ -61,18 +64,21 @@ struct rw_event {
pthread_mutex_t mutex; pthread_mutex_t mutex;
}; };
void rw_event_init(struct rw_event *rwe) { static void
rw_event_init (struct rw_event *rwe) {
rwe->e = 0; rwe->e = 0;
ctpair_rwlock_init(&rwe->the_rwlock); ctpair_rwlock_init(&rwe->the_rwlock);
int r = pthread_mutex_init(&rwe->mutex, 0); assert(r == 0); int r = pthread_mutex_init(&rwe->mutex, 0); assert(r == 0);
} }
void rw_event_destroy(struct rw_event *rwe) { static void
rw_event_destroy (struct rw_event *rwe) {
ctpair_rwlock_destroy(&rwe->the_rwlock); ctpair_rwlock_destroy(&rwe->the_rwlock);
int r = pthread_mutex_destroy(&rwe->mutex); assert(r == 0); int r = pthread_mutex_destroy(&rwe->mutex); assert(r == 0);
} }
void *test_writer_priority_thread(void *arg) { static void *
test_writer_priority_thread (void *arg) {
struct rw_event *rwe = arg; struct rw_event *rwe = arg;
int r; int r;
...@@ -91,7 +97,8 @@ void *test_writer_priority_thread(void *arg) { ...@@ -91,7 +97,8 @@ void *test_writer_priority_thread(void *arg) {
// test writer priority over new readers // test writer priority over new readers
void test_writer_priority() { static void
test_writer_priority (void) {
struct rw_event rw_event, *rwe = &rw_event; struct rw_event rw_event, *rwe = &rw_event;
int r; int r;
...@@ -131,7 +138,8 @@ void test_writer_priority() { ...@@ -131,7 +138,8 @@ void test_writer_priority() {
// test single writer // test single writer
void *test_single_writer_thread(void *arg) { static void *
test_single_writer_thread (void *arg) {
struct rw_event *rwe = arg; struct rw_event *rwe = arg;
int r; int r;
...@@ -145,7 +153,8 @@ void *test_single_writer_thread(void *arg) { ...@@ -145,7 +153,8 @@ void *test_single_writer_thread(void *arg) {
return arg; return arg;
} }
void test_single_writer() { static void
test_single_writer (void) {
struct rw_event rw_event, *rwe = &rw_event; struct rw_event rw_event, *rwe = &rw_event;
int r; int r;
......
...@@ -70,7 +70,7 @@ static void writeit (void) { ...@@ -70,7 +70,7 @@ static void writeit (void) {
CACHEKEY key = make_blocknum(i*BLOCKSIZE); CACHEKEY key = make_blocknum(i*BLOCKSIZE);
u_int32_t fullhash = toku_cachetable_hash(f, key); u_int32_t fullhash = toku_cachetable_hash(f, key);
int j; int j;
for (j=0; j<BLOCKSIZE; j++) ((char*)buf)[j]=(i+j)%256; for (j=0; j<BLOCKSIZE; j++) ((char*)buf)[j]=(char)((i+j)%256);
r = toku_cachetable_put(f, key, fullhash, buf, BLOCKSIZE, f_flush, f_fetch, 0); assert(r==0); r = toku_cachetable_put(f, key, fullhash, buf, BLOCKSIZE, f_flush, f_fetch, 0); assert(r==0);
r = toku_cachetable_unpin(f, key, fullhash, 0, BLOCKSIZE); assert(r==0); r = toku_cachetable_unpin(f, key, fullhash, 0, BLOCKSIZE); assert(r==0);
} }
......
...@@ -53,7 +53,8 @@ static void *my_malloc_always_fails(size_t n, const __malloc_ptr_t p) { ...@@ -53,7 +53,8 @@ static void *my_malloc_always_fails(size_t n, const __malloc_ptr_t p) {
// verify that cachetable creation and close works // verify that cachetable creation and close works
void test_cachetable_create() { static void
test_cachetable_create(void) {
CACHETABLE ct = 0; CACHETABLE ct = 0;
int r; int r;
r = toku_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
...@@ -64,7 +65,8 @@ void test_cachetable_create() { ...@@ -64,7 +65,8 @@ void test_cachetable_create() {
// verify that cachetable create with no memory returns ENOMEM // verify that cachetable create with no memory returns ENOMEM
void test_cachetable_create_no_memory() { static void
test_cachetable_create_no_memory (void) {
void *(*orig_malloc_hook)(size_t, const __malloc_ptr_t) = __malloc_hook; void *(*orig_malloc_hook)(size_t, const __malloc_ptr_t) = __malloc_hook;
__malloc_hook = my_malloc_always_fails; __malloc_hook = my_malloc_always_fails;
CACHETABLE ct = 0; CACHETABLE ct = 0;
...@@ -413,7 +415,7 @@ static void test_dirty_flush(CACHEFILE f, ...@@ -413,7 +415,7 @@ static void test_dirty_flush(CACHEFILE f,
BOOL keep, BOOL keep,
LSN modified_lsn __attribute__((__unused__)), LSN modified_lsn __attribute__((__unused__)),
BOOL rename_p __attribute__((__unused__))) { BOOL rename_p __attribute__((__unused__))) {
if (verbose) printf("test_dirty_flush %p %" PRId64 " %p %ld %d %d\n", f, key.b, value, size, do_write, keep); if (verbose) printf("test_dirty_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size, do_write, keep);
} }
static int test_dirty_fetch(CACHEFILE f, CACHEKEY key, u_int32_t fullhash, void **value_ptr, long *size_ptr, void *arg, LSN *written_lsn) { static int test_dirty_fetch(CACHEFILE f, CACHEKEY key, u_int32_t fullhash, void **value_ptr, long *size_ptr, void *arg, LSN *written_lsn) {
...@@ -538,7 +540,7 @@ static void test_size_flush_callback(CACHEFILE f, ...@@ -538,7 +540,7 @@ static void test_size_flush_callback(CACHEFILE f,
BOOL keep, BOOL keep,
LSN modified_lsn __attribute__((__unused__)), LSN modified_lsn __attribute__((__unused__)),
BOOL rename_p __attribute__((__unused__))) { BOOL rename_p __attribute__((__unused__))) {
if (test_size_debug && verbose) printf("test_size_flush %p %" PRId64 " %p %ld %d %d\n", f, key.b, value, size, do_write, keep); if (test_size_debug && verbose) printf("test_size_flush %p %" PRId64 " %p %ld %u %u\n", f, key.b, value, size, do_write, keep);
if (keep) { if (keep) {
assert(do_write != 0); assert(do_write != 0);
test_size_flush_key = key; test_size_flush_key = key;
......
...@@ -240,7 +240,8 @@ static void test_chaining (void) { ...@@ -240,7 +240,8 @@ static void test_chaining (void) {
test_mutex_destroy(); test_mutex_destroy();
} }
void __attribute__((__noreturn__)) usage (const char *progname) { static void __attribute__((__noreturn__))
usage (const char *progname) {
fprintf(stderr, "Usage:\n %s [-v] [-q]\n", progname); fprintf(stderr, "Usage:\n %s [-v] [-q]\n", progname);
exit(1); exit(1);
} }
......
...@@ -5,14 +5,34 @@ ...@@ -5,14 +5,34 @@
#include "test.h" #include "test.h"
#include "cachetable.h" #include "cachetable.h"
void flush() { static void
flush (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
long s __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
LSN m __attribute__((__unused__)),
BOOL r __attribute__((__unused__))
) {
/* Do nothing */
} }
int fetch() { static int
fetch (CACHEFILE f __attribute__((__unused__)),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
long *sizep __attribute__((__unused__)),
void *extraargs __attribute__((__unused__)),
LSN *written_lsn __attribute__((__unused__))
) {
return 0; return 0;
} }
void cachetable_unpin_test(int n) { static void
cachetable_unpin_test (int n) {
const int test_limit = 2*n; const int test_limit = 2*n;
int r; int r;
CACHETABLE ct; CACHETABLE ct;
......
...@@ -13,12 +13,14 @@ struct ctpair { ...@@ -13,12 +13,14 @@ struct ctpair {
PAIR next_wq; PAIR next_wq;
}; };
PAIR new_pair() { static PAIR
new_pair (void) {
PAIR p = (PAIR) malloc(sizeof *p); assert(p); PAIR p = (PAIR) malloc(sizeof *p); assert(p);
return p; return p;
} }
void destroy_pair(PAIR p) { static void
destroy_pair(PAIR p) {
free(p); free(p);
} }
...@@ -26,7 +28,8 @@ void destroy_pair(PAIR p) { ...@@ -26,7 +28,8 @@ void destroy_pair(PAIR p) {
// test simple create and destroy // test simple create and destroy
void test_create_destroy() { static void
test_create_destroy (void) {
struct writequeue writequeue, *wq = &writequeue; struct writequeue writequeue, *wq = &writequeue;
writequeue_init(wq); writequeue_init(wq);
assert(writequeue_empty(wq)); assert(writequeue_empty(wq));
...@@ -35,7 +38,8 @@ void test_create_destroy() { ...@@ -35,7 +38,8 @@ void test_create_destroy() {
// verify that the wq implements FIFO ordering // verify that the wq implements FIFO ordering
void test_simple_enq_deq(int n) { static void
test_simple_enq_deq (int n) {
struct writequeue writequeue, *wq = &writequeue; struct writequeue writequeue, *wq = &writequeue;
int r; int r;
pthread_mutex_t mutex; pthread_mutex_t mutex;
...@@ -63,7 +67,8 @@ void test_simple_enq_deq(int n) { ...@@ -63,7 +67,8 @@ void test_simple_enq_deq(int n) {
// setting the wq closed should cause deq to return EINVAL // setting the wq closed should cause deq to return EINVAL
void test_set_closed() { static void
test_set_closed (void) {
struct writequeue writequeue, *wq = &writequeue; struct writequeue writequeue, *wq = &writequeue;
writequeue_init(wq); writequeue_init(wq);
writequeue_set_closed(wq); writequeue_set_closed(wq);
...@@ -79,17 +84,20 @@ struct writequeue_with_mutex { ...@@ -79,17 +84,20 @@ struct writequeue_with_mutex {
pthread_mutex_t mutex; pthread_mutex_t mutex;
}; };
void writequeue_with_mutex_init(struct writequeue_with_mutex *wqm) { static void
writequeue_with_mutex_init (struct writequeue_with_mutex *wqm) {
writequeue_init(&wqm->writequeue); writequeue_init(&wqm->writequeue);
int r = pthread_mutex_init(&wqm->mutex, 0); assert(r == 0); int r = pthread_mutex_init(&wqm->mutex, 0); assert(r == 0);
} }
void writequeue_with_mutex_destroy(struct writequeue_with_mutex *wqm) { static void
writequeue_with_mutex_destroy (struct writequeue_with_mutex *wqm) {
writequeue_destroy(&wqm->writequeue); writequeue_destroy(&wqm->writequeue);
int r = pthread_mutex_destroy(&wqm->mutex); assert(r == 0); int r = pthread_mutex_destroy(&wqm->mutex); assert(r == 0);
} }
void *test_set_closed_waiter(void *arg) { static void *
test_set_closed_waiter(void *arg) {
struct writequeue_with_mutex *wqm = arg; struct writequeue_with_mutex *wqm = arg;
int r; int r;
...@@ -101,7 +109,8 @@ void *test_set_closed_waiter(void *arg) { ...@@ -101,7 +109,8 @@ void *test_set_closed_waiter(void *arg) {
return arg; return arg;
} }
void test_set_closed_thread() { static void
test_set_closed_thread (void) {
struct writequeue_with_mutex writequeue_with_mutex, *wqm = &writequeue_with_mutex; struct writequeue_with_mutex writequeue_with_mutex, *wqm = &writequeue_with_mutex;
int r; int r;
...@@ -128,20 +137,22 @@ struct rwfc { ...@@ -128,20 +137,22 @@ struct rwfc {
int current, limit; int current, limit;
}; };
void rwfc_init(struct rwfc *rwfc, int limit) { static void rwfc_init (struct rwfc *rwfc, int limit) {
int r; int r;
r = pthread_mutex_init(&rwfc->mutex, 0); assert(r == 0); r = pthread_mutex_init(&rwfc->mutex, 0); assert(r == 0);
writequeue_init(&rwfc->writequeue); writequeue_init(&rwfc->writequeue);
rwfc->current = 0; rwfc->limit = limit; rwfc->current = 0; rwfc->limit = limit;
} }
void rwfc_destroy(struct rwfc *rwfc) { static void
rwfc_destroy (struct rwfc *rwfc) {
int r; int r;
writequeue_destroy(&rwfc->writequeue); writequeue_destroy(&rwfc->writequeue);
r = pthread_mutex_destroy(&rwfc->mutex); assert(r == 0); r = pthread_mutex_destroy(&rwfc->mutex); assert(r == 0);
} }
void *rwfc_reader(void *arg) { static void *
rwfc_reader (void *arg) {
struct rwfc *rwfc = arg; struct rwfc *rwfc = arg;
int r; int r;
while (1) { while (1) {
...@@ -162,7 +173,8 @@ void *rwfc_reader(void *arg) { ...@@ -162,7 +173,8 @@ void *rwfc_reader(void *arg) {
return arg; return arg;
} }
void test_flow_control(int limit, int n) { static void
test_flow_control (int limit, int n) {
struct rwfc my_rwfc, *rwfc = &my_rwfc; struct rwfc my_rwfc, *rwfc = &my_rwfc;
int r; int r;
rwfc_init(rwfc, limit); rwfc_init(rwfc, limit);
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
int verbose; int verbose;
void test_fifo_create() { static void
test_fifo_create (void) {
int r; int r;
FIFO f; FIFO f;
...@@ -19,7 +20,8 @@ void test_fifo_create() { ...@@ -19,7 +20,8 @@ void test_fifo_create() {
assert(f == 0); assert(f == 0);
} }
void test_fifo_enq(int n) { static void
test_fifo_enq (int n) {
int r; int r;
FIFO f; FIFO f;
......
...@@ -9,11 +9,13 @@ struct testlist { ...@@ -9,11 +9,13 @@ struct testlist {
int tag; int tag;
}; };
void testlist_init(struct testlist *tl, int tag) { static void
testlist_init (struct testlist *tl, int tag) {
tl->tag = tag; tl->tag = tag;
} }
void test_push_pop(int n) { static void
test_push_pop (int n) {
int i; int i;
struct list head; struct list head;
...@@ -43,7 +45,8 @@ void test_push_pop(int n) { ...@@ -43,7 +45,8 @@ void test_push_pop(int n) {
assert(list_empty(&head)); assert(list_empty(&head));
} }
void test_push_pop_head(int n) { static void
test_push_pop_head (int n) {
int i; int i;
struct list head; struct list head;
...@@ -74,7 +77,8 @@ void test_push_pop_head(int n) { ...@@ -74,7 +77,8 @@ void test_push_pop_head(int n) {
assert(list_empty(&head)); assert(list_empty(&head));
} }
void test_push_head_pop(int n) { static void
test_push_head_pop (int n) {
int i; int i;
struct list head; struct list head;
...@@ -106,7 +110,8 @@ void test_push_head_pop(int n) { ...@@ -106,7 +110,8 @@ void test_push_head_pop(int n) {
} }
// cant move an empty list // cant move an empty list
void test_move_empty() { static void
test_move_empty (void) {
struct list h1, h2; struct list h1, h2;
list_init(&h1); list_init(&h1);
...@@ -116,7 +121,8 @@ void test_move_empty() { ...@@ -116,7 +121,8 @@ void test_move_empty() {
assert(list_empty(&h1)); assert(list_empty(&h1));
} }
void test_move(int n) { static void
test_move (int n) {
struct list h1, h2; struct list h1, h2;
int i; int i;
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include "memory.h" #include "memory.h"
#include "mempool.h" #include "mempool.h"
void test_mempool_limits(size_t size) { static void
test_mempool_limits (size_t size) {
void *base = malloc(size); void *base = malloc(size);
struct mempool mempool; struct mempool mempool;
toku_mempool_init(&mempool, base, size); toku_mempool_init(&mempool, base, size);
...@@ -24,7 +25,8 @@ void test_mempool_limits(size_t size) { ...@@ -24,7 +25,8 @@ void test_mempool_limits(size_t size) {
free(base); free(base);
} }
void test_mempool_malloc_mfree(size_t size) { static void
test_mempool_malloc_mfree (size_t size) {
void *base = malloc(size); void *base = malloc(size);
struct mempool mempool; struct mempool mempool;
toku_mempool_init(&mempool, base, size); toku_mempool_init(&mempool, base, size);
......
This diff is collapsed.
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
static TOKUTXN const null_txn = 0; static TOKUTXN const null_txn = 0;
void doit (void) { static void
doit (void) {
int r; int r;
CACHETABLE ct; CACHETABLE ct;
BRT t; BRT t;
......
...@@ -13,7 +13,8 @@ static const char fname[]= __FILE__ ".brt"; ...@@ -13,7 +13,8 @@ static const char fname[]= __FILE__ ".brt";
static TOKUTXN const null_txn = 0; static TOKUTXN const null_txn = 0;
static DB * const null_db = 0; static DB * const null_db = 0;
void test_overflow (void) { static void
test_overflow (void) {
BRT t; BRT t;
CACHETABLE ct; CACHETABLE ct;
u_int32_t nodesize = 1<<20; u_int32_t nodesize = 1<<20;
...@@ -28,7 +29,7 @@ void test_overflow (void) { ...@@ -28,7 +29,7 @@ void test_overflow (void) {
memset(buf, 'a', vsize); memset(buf, 'a', vsize);
int i; int i;
for (i=0; i<8; i++) { for (i=0; i<8; i++) {
char key[]={'a'+i, 0}; char key[]={(char)('a'+i), 0};
toku_brt_insert(t, toku_fill_dbt(&k, key, 2), toku_fill_dbt(&v,buf,sizeof(buf)), null_txn); toku_brt_insert(t, toku_fill_dbt(&k, key, 2), toku_fill_dbt(&v,buf,sizeof(buf)), null_txn);
} }
r = toku_close_brt(t, 0); assert(r==0); r = toku_close_brt(t, 0); assert(r==0);
......
...@@ -21,7 +21,8 @@ BRT t; ...@@ -21,7 +21,8 @@ BRT t;
int fnamelen; int fnamelen;
char *fname; char *fname;
void doit (void) { static void
doit (void) {
BLOCKNUM nodea,nodeb; BLOCKNUM nodea,nodeb;
u_int32_t fingerprinta=0; u_int32_t fingerprinta=0;
......
...@@ -47,7 +47,8 @@ BRT t; ...@@ -47,7 +47,8 @@ BRT t;
int fnamelen; int fnamelen;
char *fname; char *fname;
void doit (int ksize __attribute__((__unused__))) { static void
doit (int ksize __attribute__((__unused__))) {
BLOCKNUM cnodes[BRT_FANOUT], bnode, anode; BLOCKNUM cnodes[BRT_FANOUT], bnode, anode;
u_int32_t fingerprints[BRT_FANOUT]; u_int32_t fingerprints[BRT_FANOUT];
......
...@@ -17,7 +17,8 @@ struct my_threadpool { ...@@ -17,7 +17,8 @@ struct my_threadpool {
int closed; int closed;
}; };
void my_threadpool_init(struct my_threadpool *my_threadpool, int max_threads) { static void
my_threadpool_init (struct my_threadpool *my_threadpool, int max_threads) {
int r; int r;
r = threadpool_create(&my_threadpool->threadpool, max_threads); assert(r == 0); r = threadpool_create(&my_threadpool->threadpool, max_threads); assert(r == 0);
assert(my_threadpool != 0); assert(my_threadpool != 0);
...@@ -26,7 +27,8 @@ void my_threadpool_init(struct my_threadpool *my_threadpool, int max_threads) { ...@@ -26,7 +27,8 @@ void my_threadpool_init(struct my_threadpool *my_threadpool, int max_threads) {
my_threadpool->closed = 0; my_threadpool->closed = 0;
} }
void my_threadpool_destroy(struct my_threadpool *my_threadpool) { static void
my_threadpool_destroy (struct my_threadpool *my_threadpool) {
int r; int r;
r = pthread_mutex_lock(&my_threadpool->mutex); assert(r == 0); r = pthread_mutex_lock(&my_threadpool->mutex); assert(r == 0);
my_threadpool->closed = 1; my_threadpool->closed = 1;
...@@ -39,7 +41,8 @@ void my_threadpool_destroy(struct my_threadpool *my_threadpool) { ...@@ -39,7 +41,8 @@ void my_threadpool_destroy(struct my_threadpool *my_threadpool) {
r = pthread_cond_destroy(&my_threadpool->wait); assert(r == 0); r = pthread_cond_destroy(&my_threadpool->wait); assert(r == 0);
} }
void *fbusy(void *arg) { static void *
fbusy (void *arg) {
struct my_threadpool *my_threadpool = arg; struct my_threadpool *my_threadpool = arg;
int r; int r;
...@@ -52,7 +55,8 @@ void *fbusy(void *arg) { ...@@ -52,7 +55,8 @@ void *fbusy(void *arg) {
return arg; return arg;
} }
void *fidle(void *arg) { static void *
fidle (void *arg) {
struct my_threadpool *my_threadpool = arg; struct my_threadpool *my_threadpool = arg;
int r; int r;
...@@ -74,7 +78,8 @@ static void *my_malloc_always_fails(size_t n, const __malloc_ptr_t p) { ...@@ -74,7 +78,8 @@ static void *my_malloc_always_fails(size_t n, const __malloc_ptr_t p) {
} }
#endif #endif
int usage() { static int
usage (void) {
printf("threadpool-test: [-v] [-malloc-fail] [N]\n"); printf("threadpool-test: [-v] [-malloc-fail] [N]\n");
printf("-malloc-fail simulate malloc failures\n"); printf("-malloc-fail simulate malloc failures\n");
printf("N max number of threads in the thread pool\n"); printf("N max number of threads in the thread pool\n");
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
void test0 (void) { static void
test0 (void) {
u_int32_t c = x1764_memory("", 0); u_int32_t c = x1764_memory("", 0);
assert(c==0); assert(c==0);
struct x1764 cs; struct x1764 cs;
...@@ -13,7 +14,8 @@ void test0 (void) { ...@@ -13,7 +14,8 @@ void test0 (void) {
assert(c==0); assert(c==0);
} }
void test1 (void) { static void
test1 (void) {
u_int64_t v=0x123456789abcdef0ULL; u_int64_t v=0x123456789abcdef0ULL;
u_int32_t c; u_int32_t c;
int i; int i;
...@@ -27,7 +29,8 @@ void test1 (void) { ...@@ -27,7 +29,8 @@ void test1 (void) {
} }
// Compute checksums incrementally, using various strides // Compute checksums incrementally, using various strides
void test2 (void) { static void
test2 (void) {
enum { N=200 }; enum { N=200 };
char v[N]; char v[N];
int i; int i;
......
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