Commit 0d2788eb 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@6371 c7de825b-a66e-492c-adef-691d508d4ae1
parent 31da3f37
......@@ -42,7 +42,10 @@ ifneq ($(CC),icc)
CFLAGS += -Werror -Wextra -Wcast-align -Wbad-function-cast -Wmissing-noreturn -g3 -ggdb3
else
CFLAGS += -g
CFLAGS += -diag-disable 177 # Don't complain about static variables that are not used
CFLAGS += -diag-disable 177 # Don't complain about static variables that are not used.
CFLAGS += -diag-disable 1324 # Don't complain about rdtsc clobbering its registers more than once.
CFLAGS += -diag-disable 981 # Don't complain about "operands are evaluated in unspecified order". This seems to be generated whenever more than one argument to a function or operand is computed by function call.
CFLAGS += -diag-disable 589 # Don't complain about goto into a block that skips initializing variables. GCC catches the actual uninitialized variables.
endif
LDFLAGS = $(OPTFLAGS) -g $(GCOV_FLAGS) $(PROF_FLAGS) -lz -lpthread
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=500
......
......@@ -74,7 +74,7 @@ unlock_for_pwrite (void) {
assert(r==0);
}
ssize_t
static ssize_t
toku_pwrite (int fd, const void *buf, size_t count, off_t offset)
// requires that the pwrite has been locked
{
......@@ -99,7 +99,8 @@ static const int brtnode_header_overhead = (8+ // magic "tokunode" or "tokulea
static int deserialize_fifo_at (int fd, off_t at, FIFO *fifo);
int addupsize (OMTVALUE lev, u_int32_t UU(idx), void *vp) {
static int
addupsize (OMTVALUE lev, u_int32_t UU(idx), void *vp) {
LEAFENTRY le=lev;
unsigned int *ip=vp;
(*ip) += OMT_ITEM_OVERHEAD + leafentry_disksize(le);
......@@ -160,14 +161,15 @@ unsigned int toku_serialize_brtnode_size (BRTNODE node) {
result+=node->u.l.n_bytes_in_buffer;
if (toku_memory_check) {
unsigned int slowresult = toku_serialize_brtnode_size_slow(node);
if (result!=slowresult) printf("%s:%d result=%d slowresult=%d\n", __FILE__, __LINE__, result, slowresult);
if (result!=slowresult) printf("%s:%d result=%u slowresult=%u\n", __FILE__, __LINE__, result, slowresult);
assert(result==slowresult);
}
}
return result;
}
int wbufwriteleafentry (OMTVALUE lev, u_int32_t UU(idx), void *v) {
static int
wbufwriteleafentry (OMTVALUE lev, u_int32_t UU(idx), void *v) {
LEAFENTRY le=lev;
struct wbuf *thisw=v;
wbuf_LEAFENTRY(thisw, le);
......@@ -248,7 +250,8 @@ void toku_serialize_brtnode_to (int fd, BLOCKNUM blocknum, BRTNODE node, struct
wbuf_int(&w, toku_fifo_n_entries(BNC_BUFFER(node,i)));
FIFO_ITERATE(BNC_BUFFER(node,i), key, keylen, data, datalen, type, xid,
({
wbuf_char(&w, type);
assert(type>0 && type<256);
wbuf_char(&w, (unsigned char)type);
wbuf_TXNID(&w, xid);
wbuf_bytes(&w, key, keylen);
wbuf_bytes(&w, data, datalen);
......@@ -276,7 +279,7 @@ void toku_serialize_brtnode_to (int fd, BLOCKNUM blocknum, BRTNODE node, struct
#endif
if (calculated_size!=w.ndone)
printf("%s:%d w.done=%d calculated_size=%d\n", __FILE__, __LINE__, w.ndone, calculated_size);
printf("%s:%d w.done=%u calculated_size=%u\n", __FILE__, __LINE__, w.ndone, calculated_size);
assert(calculated_size==w.ndone);
// The uncompressed part of the header is
......@@ -302,7 +305,7 @@ void toku_serialize_brtnode_to (int fd, BLOCKNUM blocknum, BRTNODE node, struct
assert(r==Z_OK);
}
if (0) printf("Size before compressing %d, after compression %ld\n", calculated_size-uncompressed_magic_len, compressed_len);
if (0) printf("Size before compressing %u, after compression %lu\n", calculated_size-uncompressed_magic_len, compressed_len);
((int32_t*)(compressed_buf+uncompressed_magic_len))[0] = htonl(compressed_len);
((int32_t*)(compressed_buf+uncompressed_magic_len))[1] = htonl(uncompressed_len);
......@@ -380,7 +383,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
if (compressed_size<=0 || compressed_size>(1<<30)) { r = DB_BADFORMAT; goto died0; }
uncompressed_size = ntohl(*(u_int32_t*)(&uncompressed_header[uncompressed_magic_len+4]));
if (uncompressed_size<=0 || uncompressed_size>(1<<30)) { r = DB_BADFORMAT; goto died0; }
if (0) printf("Compressed size = %d, uncompressed size=%d\n", compressed_size, uncompressed_size);
if (0) printf("Compressed size = %u, uncompressed size=%u\n", compressed_size, uncompressed_size);
}
unsigned char *MALLOC_N(compressed_size, compressed_data);
......@@ -566,7 +569,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
if (actual_sum!=result->local_fingerprint) {
//fprintf(stderr, "%s:%d Corrupted checksum stored=%08x rand=%08x actual=%08x height=%d n_keys=%d\n", __FILE__, __LINE__, result->rand4fingerprint, result->local_fingerprint, actual_sum, result->height, n_in_buf);
return DB_BADFORMAT;
goto died_21;
// goto died_21;
} else {
//fprintf(stderr, "%s:%d Good checksum=%08x height=%d\n", __FILE__, __LINE__, actual_sum, result->height);
}
......@@ -605,7 +608,8 @@ struct sum_info {
u_int32_t fp;
};
int sum_item (OMTVALUE lev, u_int32_t UU(idx), void *vsi) {
static int
sum_item (OMTVALUE lev, u_int32_t UU(idx), void *vsi) {
LEAFENTRY le=lev;
struct sum_info *si = vsi;
si->count++;
......@@ -736,7 +740,8 @@ int toku_serialize_brt_header_to (int fd, struct brt_header *h) {
}
// We only deserialize brt header once and then share everything with all the brts.
int deserialize_brtheader (u_int32_t size, int fd, DISKOFF off, struct brt_header **brth) {
static int
deserialize_brtheader (u_int32_t size, int fd, DISKOFF off, struct brt_header **brth) {
// We already know the first 8 bytes are "tokudata", and we read in the size.
struct brt_header *MALLOC(h);
if (h==0) return errno;
......@@ -895,7 +900,8 @@ int toku_serialize_fifo_at (int fd, off_t freeoff, FIFO fifo) {
assert(buf!=0);
struct wbuf w;
wbuf_init(&w, buf, size);
wbuf_char(&w, type);
assert(type>=0 && type<256);
wbuf_char(&w, (unsigned char)type);
wbuf_TXNID(&w, xid);
wbuf_bytes(&w, key, keylen);
//printf("%s:%d Writing %d bytes: %s\n", __FILE__, __LINE__, vallen, (char*)val);
......@@ -914,7 +920,8 @@ int toku_serialize_fifo_at (int fd, off_t freeoff, FIFO fifo) {
return 0;
}
int read_int (int fd, off_t *at, u_int32_t *result) {
static int
read_int (int fd, off_t *at, u_int32_t *result) {
int v;
ssize_t r = pread(fd, &v, 4, *at);
if (r<0) return errno;
......@@ -924,7 +931,8 @@ int read_int (int fd, off_t *at, u_int32_t *result) {
return 0;
}
int read_char (int fd, off_t *at, char *result) {
static int
read_char (int fd, off_t *at, char *result) {
ssize_t r = pread(fd, result, 1, *at);
if (r<0) return errno;
assert(r==1);
......@@ -932,7 +940,8 @@ int read_char (int fd, off_t *at, char *result) {
return 0;
}
int read_u_int64_t (int fd, off_t *at, u_int64_t *result) {
static int
read_u_int64_t (int fd, off_t *at, u_int64_t *result) {
u_int32_t v1=0,v2=0;
int r;
if ((r = read_int(fd, at, &v1))) return r;
......@@ -941,7 +950,8 @@ int read_u_int64_t (int fd, off_t *at, u_int64_t *result) {
return 0;
}
int read_nbytes (int fd, off_t *at, char **data, u_int32_t len) {
static int
read_nbytes (int fd, off_t *at, char **data, u_int32_t len) {
char *result = toku_malloc(len);
if (result==0) return errno;
ssize_t r = pread(fd, result, len, *at);
......
......@@ -50,7 +50,7 @@
#define VERIFY_NODE(n) ((void)0)
#endif
extern long long n_items_malloced;
long long n_items_malloced;
static void verify_local_fingerprint_nonleaf (BRTNODE node);
......@@ -168,7 +168,7 @@ void toku_brtnode_flush_callback (CACHEFILE cachefile, BLOCKNUM nodename, void *
// toku_pma_verify_fingerprint(brtnode->u.l.buffer, brtnode->rand4fingerprint, brtnode->subtree_fingerprint);
// }
if (0) {
printf("%s:%d toku_brtnode_flush_callback %p thisnodename=%" PRId64 " keep_me=%d height=%d", __FILE__, __LINE__, brtnode, brtnode->thisnodename.b, keep_me, brtnode->height);
printf("%s:%d toku_brtnode_flush_callback %p thisnodename=%" PRId64 " keep_me=%u height=%d", __FILE__, __LINE__, brtnode, brtnode->thisnodename.b, keep_me, brtnode->height);
if (brtnode->height==0) printf(" buf=%p mempool-base=%p", brtnode->u.l.buffer, brtnode->u.l.buffer_mempool.base);
printf("\n");
}
......@@ -280,7 +280,8 @@ typedef struct kvpair {
unsigned int vallen;
} *KVPAIR;
int allocate_diskblocknumber (BLOCKNUM *res, BRT brt, TOKULOGGER logger __attribute__((__unused__))) {
static int
allocate_diskblocknumber (BLOCKNUM *res, BRT brt, TOKULOGGER logger __attribute__((__unused__))) {
assert(brt->h->free_blocks.b == -1); // no blocks in the free list
BLOCKNUM result = brt->h->unused_blocks;
brt->h->unused_blocks.b++;
......@@ -289,7 +290,8 @@ int allocate_diskblocknumber (BLOCKNUM *res, BRT brt, TOKULOGGER logger __attrib
return 0;
}
u_int32_t mp_pool_size_for_nodesize (u_int32_t nodesize) {
static u_int32_t
mp_pool_size_for_nodesize (u_int32_t nodesize) {
#if 1
return nodesize+nodesize/4;
#else
......@@ -515,7 +517,7 @@ static int brtleaf_split (TOKULOGGER logger, FILENUM filenum, BRT t, BRTNODE nod
}
LSN lsn={0};
r = toku_log_leafsplit(logger, &lsn, 0, filenum, node->thisnodename, B->thisnodename, n_leafentries, break_at, node->nodesize, B->rand4fingerprint, (t->flags&TOKU_DB_DUPSORT)!=0);
r = toku_log_leafsplit(logger, &lsn, 0, filenum, node->thisnodename, B->thisnodename, n_leafentries, break_at, node->nodesize, B->rand4fingerprint, (u_int8_t)((t->flags&TOKU_DB_DUPSORT)!=0));
if (logger) {
node->log_lsn = lsn;
B->log_lsn = lsn;
......@@ -776,10 +778,10 @@ static int push_brt_cmd_down_only_if_it_wont_push_more_else_put_here (BRT t, BRT
r=insert_to_buffer_in_nonleaf(node, childnum_of_node, k, v, cmd->type, cmd->xid);
}
if (newsize_bounded < toku_serialize_brtnode_size(child)) {
fprintf(stderr, "%s:%d size estimate is messed up. newsize_bounded=%d actual_size=%d child_height=%d to_child=%d\n",
fprintf(stderr, "%s:%d size estimate is messed up. newsize_bounded=%u actual_size=%u child_height=%d to_child=%d\n",
__FILE__, __LINE__, newsize_bounded, toku_serialize_brtnode_size(child), child->height, to_child);
fprintf(stderr, " cmd->type=%s cmd->xid=%lld\n", unparse_cmd_type(cmd->type), (unsigned long long)cmd->xid);
fprintf(stderr, " oldsize=%d k->size=%d v->size=%d\n", oldsize, k->size, v->size);
fprintf(stderr, " cmd->type=%s cmd->xid=%llu\n", unparse_cmd_type(cmd->type), (unsigned long long)cmd->xid);
fprintf(stderr, " oldsize=%u k->size=%u v->size=%u\n", oldsize, k->size, v->size);
assert(toku_serialize_brtnode_size(child)<=child->nodesize);
//assert(newsize_bounded >= toku_serialize_brtnode_size(child)); // Don't abort on this
}
......
#include <stdio.h>
#include "../include/rdtsc.h"
#include "trace_mem.h"
// customize this as required
#define NTRACE 0
......@@ -25,8 +26,7 @@ void toku_add_trace_mem(const char *str __attribute__((unused)),
#endif
}
void toku_print_trace_mem() __attribute__((__visibility__("default")));
void toku_print_trace_mem() {
void toku_print_trace_mem(void) {
#if NTRACE
int i = toku_next_trace;
do {
......
......@@ -11,5 +11,5 @@ void toku_add_trace_mem(const char *str, int n);
// add an entry to the end of the trace which consists of a string
// pointer, a number, and the processor timestamp
void toku_print_trace_mem();
void toku_print_trace_mem(void) __attribute__((__visibility__("default")));
// print the trace
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