(rarchdb) Silence some warnings

This commit is contained in:
twinaphex 2015-01-09 17:55:56 +01:00
parent 8fc4db23dc
commit 215042cdbb
3 changed files with 32 additions and 22 deletions

View File

@ -208,16 +208,20 @@ static int binsearch(const void *buff, const void *item, uint64_t count, uint8_t
int rarchdb_find_entry(struct rarchdb *db, const char *index_name, const void *key)
{
struct rarchdb_index idx;
uint64_t offset;
ssize_t nread = 0;
int rv;
void *buff;
uint64_t offset;
ssize_t bufflen, nread = 0;
if (rarchdb_find_index(db, index_name, &idx) < 0)
{
rarchdb_read_reset(db);
return -1;
}
size_t bufflen = idx.next;
void* buff = malloc(bufflen);
bufflen = idx.next;
buff = malloc(bufflen);
if (!buff)
return -ENOMEM;

View File

@ -401,7 +401,9 @@ static int read_buff(int fd, size_t size, char** pbuff, uint64_t *len)
static int read_map(int fd, uint32_t len, struct rmsgpack_read_callbacks *callbacks, void *data)
{
int rv, i;
int rv;
unsigned i;
if (
callbacks->read_map_start &&
(rv = callbacks->read_map_start(len, data)) < 0)
@ -420,7 +422,8 @@ static int read_map(int fd, uint32_t len, struct rmsgpack_read_callbacks *callba
static int read_array(int fd, uint32_t len, struct rmsgpack_read_callbacks *callbacks, void *data)
{
int rv, i;
int rv;
unsigned i;
if (
callbacks->read_array_start &&

View File

@ -96,19 +96,19 @@ static int dom_read_bin(void* value, uint32_t len, void *data)
static int dom_read_map_start(uint32_t len, void *data)
{
int i;
unsigned i;
struct rmsgpack_dom_pair *items = NULL;
struct dom_reader_state *dom_state = (struct dom_reader_state*)data;
struct dom_reader_state *dom_state = (struct dom_reader_state*)data;
struct rmsgpack_dom_value *v = dom_reader_state_pop(dom_state);
v->type = RDT_MAP;
v->map.len = len;
v->map.items = NULL;
items = (struct rmsgpack_dom_pair *)calloc(len, sizeof(struct rmsgpack_dom_pair));
v->type = RDT_MAP;
v->map.len = len;
v->map.items = NULL;
if (!items)
return -ENOMEM;
items = (struct rmsgpack_dom_pair *)calloc(len, sizeof(struct rmsgpack_dom_pair));
if (!items)
return -ENOMEM;
v->map.items = items;
for (i = 0; i < len; i++)
@ -123,10 +123,11 @@ static int dom_read_map_start(uint32_t len, void *data)
static int dom_read_array_start(uint32_t len, void *data)
{
int i;
struct dom_reader_state *dom_state = (struct dom_reader_state*)data;
unsigned i;
struct dom_reader_state *dom_state = (struct dom_reader_state*)data;
struct rmsgpack_dom_value *v = dom_reader_state_pop(dom_state);
struct rmsgpack_dom_value *items = NULL;
v->type = RDT_ARRAY;
v->array.len = len;
v->array.items = NULL;
@ -159,7 +160,7 @@ static struct rmsgpack_read_callbacks dom_reader_callbacks = {
void rmsgpack_dom_value_free(struct rmsgpack_dom_value *v)
{
int i;
unsigned i;
switch (v->type)
{
@ -194,7 +195,7 @@ void rmsgpack_dom_value_free(struct rmsgpack_dom_value *v)
struct rmsgpack_dom_value *rmsgpack_dom_value_map_value(
const struct rmsgpack_dom_value *map, const struct rmsgpack_dom_value *key)
{
int i;
unsigned i;
if (map->type != RDT_MAP)
return NULL;
@ -209,7 +210,9 @@ struct rmsgpack_dom_value *rmsgpack_dom_value_map_value(
int rmsgpack_dom_value_cmp(
const struct rmsgpack_dom_value *a, const struct rmsgpack_dom_value *b)
{
int rv, i;
int rv;
unsigned i;
if (a == b)
return 1;
@ -261,7 +264,7 @@ int rmsgpack_dom_value_cmp(
void rmsgpack_dom_value_print(struct rmsgpack_dom_value *obj)
{
int i;
unsigned i;
switch (obj->type)
{
@ -322,7 +325,7 @@ void rmsgpack_dom_value_print(struct rmsgpack_dom_value *obj)
}
int rmsgpack_dom_write(int fd, const struct rmsgpack_dom_value *obj)
{
int i;
unsigned i;
int rv = 0;
int written = 0;