Commit 46f17b46 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Write leafentry code, and get things to compile. Make it more compatible with...

Write leafentry code, and get things to compile.  Make it more compatible with -Wconversion.  Addresses #558.

git-svn-id: file:///svn/tokudb@3270 c7de825b-a66e-492c-adef-691d508d4ae1
parent f4a1def6
......@@ -34,6 +34,8 @@ CFLAGS = -Wall -W -Wcast-align -Wbad-function-cast -Wextra -Wmissing-noreturn -W
LDFLAGS = $(OPTFLAGS) -g $(GCOV_FLAGS) $(PROF_FLAGS)
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
leafentry.o: CFLAGS+=-Wconversion
ifdef BRT_FANOUT
CPPFLAGS += -DBRT_FANOUT=$(BRT_FANOUT)
endif
......
......@@ -162,7 +162,7 @@ static const BRTNODE null_brtnode=0;
extern u_int32_t toku_calccrc32_kvpair (const void *key, int keylen, const void *val, int vallen);
extern u_int32_t toku_calccrc32_kvpair_struct (const struct kv_pair *kvp);
extern u_int32_t toku_calccrc32_cmd (int type, TXNID xid, const void *key, int keylen, const void *val, int vallen);
extern u_int32_t toku_calccrc32_cmd (u_int32_t type, TXNID xid, const void *key, u_int32_t keylen, const void *val, u_int32_t vallen);
extern u_int32_t toku_calccrc32_cmdstruct (BRT_CMD cmd);
// How long is the pivot key?
......
......@@ -117,10 +117,10 @@ void toku_serialize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node)
//printf("%s:%d %lld.calculated_size=%d\n", __FILE__, __LINE__, off, calculated_size);
wbuf_uint(&w, calculated_size);
wbuf_uint(&w, node->flags);
wbuf_uint(&w, node->height);
wbuf_int(&w, node->height);
//printf("%s:%d %lld rand=%08x sum=%08x height=%d\n", __FILE__, __LINE__, node->thisnodename, node->rand4fingerprint, node->subtree_fingerprint, node->height);
wbuf_int(&w, node->rand4fingerprint);
wbuf_int(&w, node->local_fingerprint);
wbuf_uint(&w, node->rand4fingerprint);
wbuf_uint(&w, node->local_fingerprint);
// printf("%s:%d wrote %08x for node %lld\n", __FILE__, __LINE__, node->local_fingerprint, (long long)node->thisnodename);
//printf("%s:%d local_fingerprint=%8x\n", __FILE__, __LINE__, node->local_fingerprint);
//printf("%s:%d w.ndone=%d n_children=%d\n", __FILE__, __LINE__, w.ndone, node->n_children);
......@@ -133,11 +133,11 @@ void toku_serialize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node)
for (i=0; i<node->u.n.n_children; i++) {
subtree_fingerprint += BNC_SUBTREE_FINGERPRINT(node, i);
}
wbuf_int(&w, subtree_fingerprint);
wbuf_uint(&w, subtree_fingerprint);
}
wbuf_int(&w, node->u.n.n_children);
for (i=0; i<node->u.n.n_children; i++) {
wbuf_int(&w, BNC_SUBTREE_FINGERPRINT(node, i));
wbuf_uint(&w, BNC_SUBTREE_FINGERPRINT(node, i));
}
//printf("%s:%d w.ndone=%d\n", __FILE__, __LINE__, w.ndone);
for (i=0; i<node->u.n.n_children-1; i++) {
......@@ -175,16 +175,16 @@ void toku_serialize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node)
}
} else {
//printf(" n_entries=%d\n", toku_pma_n_entries(node->u.l.buffer));
wbuf_int(&w, toku_gpma_n_entries(node->u.l.buffer));
wbuf_int(&w, toku_gpma_index_limit(node->u.l.buffer));
wbuf_uint(&w, toku_gpma_n_entries(node->u.l.buffer));
wbuf_uint(&w, toku_gpma_index_limit(node->u.l.buffer));
GPMA_ITERATE(node->u.l.buffer, idx, vlen, vdata,
({
struct kv_pair *p=vdata;
assert((char*)node->u.l.buffer_mempool.base<= (char*)p && (char*)p < (char*)node->u.l.buffer_mempool.base+node->u.l.buffer_mempool.size );
int keylen=kv_pair_keylen(p);
int datalen=kv_pair_vallen(p);
u_int32_t keylen=kv_pair_keylen(p);
u_int32_t datalen=kv_pair_vallen(p);
assert(vlen==sizeof(*p)+keylen+datalen);
wbuf_int(&w, idx);
wbuf_uint(&w, idx);
wbuf_bytes(&w, kv_pair_key(p), keylen);
wbuf_bytes(&w, kv_pair_val(p), datalen);
}));
......@@ -194,14 +194,14 @@ void toku_serialize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node)
wbuf_int(&w, crc32(toku_null_crc, w.buf, w.ndone));
#endif
#ifdef CRC_INCR
wbuf_int(&w, w.crc32);
wbuf_uint(&w, w.crc32);
#endif
memset(w.buf+w.ndone, 0, size-w.ndone); // fill with zeros
memset(w.buf+w.ndone, 0, (size_t)(size-w.ndone)); // fill with zeros
//write_now: printf("%s:%d Writing %d bytes\n", __FILE__, __LINE__, w.ndone);
{
ssize_t r=pwrite(fd, w.buf, size, off); // write the whole buffer, including the zeros
ssize_t r=pwrite(fd, w.buf, (size_t)size, off); // write the whole buffer, including the zeros
if (r<0) printf("r=%ld errno=%d\n", (long)r, errno);
assert(r==size);
}
......
......@@ -26,7 +26,7 @@ u_int32_t toku_calccrc32_kvpair_struct (const struct kv_pair *kvp) {
kv_pair_val_const(kvp), kv_pair_vallen(kvp));
}
u_int32_t toku_calccrc32_cmd (int type, TXNID xid, const void *key, int keylen, const void *val, int vallen) {
u_int32_t toku_calccrc32_cmd (u_int32_t type, TXNID xid, const void *key, u_int32_t keylen, const void *val, u_int32_t vallen) {
unsigned char type_c = type;
unsigned int a = htonl(xid>>32);
unsigned int b = htonl(xid&0xffffffff);
......
......@@ -141,8 +141,8 @@ static u_int32_t crc_uint32_t (u_int32_t crc, u_int32_t v) {
}
static u_int32_t crc_uint64_t (u_int32_t crc, u_int64_t v) {
crc = crc_uint32_t (crc, v>>32);
crc = crc_uint32_t (crc, v&0xffffffff);
crc = crc_uint32_t (crc, (u_int32_t)(v>>32));
crc = crc_uint32_t (crc, (u_int32_t)(v&0xffffffff));
return crc;
}
......@@ -193,9 +193,9 @@ int toku_gpma_compress_kvspace (GPMA pma, struct mempool *memp) {
toku_mempool_init(&new_kvspace, newmem, memp->size);
GPMA_ITERATE(pma, idx, len, data,
({
void *newdata = toku_mempool_malloc(&new_kvspace, len, 4);
void *newdata = toku_mempool_malloc(&new_kvspace, (size_t)len, 4);
assert(newdata);
memcpy(newdata, data, len);
memcpy(newdata, data, (size_t)len);
toku_gpma_set_at_index(pma, idx, len, newdata);
// toku_verify_gpma(pma);
}));
......@@ -206,7 +206,7 @@ int toku_gpma_compress_kvspace (GPMA pma, struct mempool *memp) {
}
void *mempool_malloc_from_gpma(GPMA pma, struct mempool *mp, u_int32_t size) {
void *mempool_malloc_from_gpma(GPMA pma, struct mempool *mp, size_t size) {
void *v = toku_mempool_malloc(mp, size, 4);
if (v==0) {
if (0 == toku_gpma_compress_kvspace(pma, mp)) {
......@@ -224,8 +224,8 @@ int le_committed (ITEMLEN klen, bytevec kval, ITEMLEN dlen, bytevec dval, GPMA p
ce=(struct contents_committed*)&le->contents[0];
ce->keylen = klen;
ce->vallen = dlen;
memcpy(&ce->data[0], kval, klen);
memcpy(&ce->data[klen], dval, dlen);
memcpy(&ce->data[0], kval, (size_t)klen);
memcpy(&ce->data[klen], dval, (size_t)dlen);
*result=le;
return 0;
}
......
......@@ -42,7 +42,7 @@ int le_provdel (ITEMLEN klen, bytevec kval, ITEMLEN dlen, bytevec dval, struct
int le_provpair (ITEMLEN klen, bytevec kval, ITEMLEN dlen, bytevec dval, struct mempool *mp, LEAFENTRY *result);
int toku_gpma_compress_kvspace (GPMA pma, struct mempool *memp);
void *mempool_malloc_from_gpma(GPMA pma, struct mempool *mp, u_int32_t size);
void *mempool_malloc_from_gpma(GPMA pma, struct mempool *mp, size_t size);
#endif
......@@ -5,9 +5,9 @@
#include "toku_assert.h"
#include <stdio.h>
void toku_mempool_init(struct mempool *mp, void *base, int size) {
void toku_mempool_init(struct mempool *mp, void *base, size_t size) {
// printf("mempool_init %p %p %d\n", mp, base, size);
assert(base != 0 && size >= 0);
assert(base != 0 && size<(1U<<31)); // used to be assert(size >= 0), but changed to size_t so now let's make sure it's not more than 2GB...
mp->base = base;
mp->size = size;
mp->free_offset = 0;
......
......@@ -25,7 +25,7 @@ struct mempool {
/* initialize the memory pool with the base address and size of a
contiguous chunk of memory */
void toku_mempool_init(struct mempool *mp, void *base, int size);
void toku_mempool_init(struct mempool *mp, void *base, size_t size);
/* finalize the memory pool */
void toku_mempool_fini(struct mempool *mp);
......
......@@ -39,7 +39,7 @@ static inline void wbuf_init (struct wbuf *w, void *buf, DISKOFF size) {
}
/* Write a character. */
static inline void wbuf_char (struct wbuf *w, int ch) {
static inline void wbuf_char (struct wbuf *w, unsigned int ch) {
assert(w->ndone<w->size);
w->buf[w->ndone++]=ch;
#ifdef CRC_INCR
......
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