Commit 80482eb4 authored by Matthieu Dorier's avatar Matthieu Dorier

added checks for NULL ptrs in visitors

parent 920f6c82
......@@ -6,6 +6,8 @@
#ifndef __MOBJECT_LOG_H
#define __MOBJECT_LOG_H
#include <stdio.h>
#define STRINGIZE(x) STRINGIZE2(x)
#define STRINGIZE2(x) #x
#define LINE_STRING STRINGIZE(__LINE__)
......
......@@ -8,6 +8,7 @@
#include "utlist.h"
#include "libmobject-store.h"
#include "omap-iter-impl.h"
#include "log.h"
void omap_iter_create(mobject_store_omap_iter_t* iter)
{
......
......@@ -45,26 +45,32 @@ void execute_read_op_visitor(read_op_visitor_t visitor, mobject_store_read_op_t
static void execute_read_op_visitor_on_stat(read_op_visitor_t visitor, rd_action_stat_t a)
{
visitor->visit_stat(visitor->uargs, a->psize, a->pmtime, a->prval);
if(visitor->visit_stat)
visitor->visit_stat(visitor->uargs, a->psize, a->pmtime, a->prval);
}
static void execute_read_op_visitor_on_read(read_op_visitor_t visitor, rd_action_read_t a)
{
visitor->visit_read(visitor->uargs, a->offset, a->len, a->buffer, a->bytes_read, a->prval);
if(visitor->visit_read)
visitor->visit_read(visitor->uargs, a->offset, a->len, a->buffer, a->bytes_read, a->prval);
}
static void execute_read_op_visitor_on_omap_get_keys(read_op_visitor_t visitor, rd_action_omap_get_keys_t a)
{
visitor->visit_omap_get_keys(visitor->uargs, a->start_after, a->max_return, a->iter, a->prval);
if(visitor->visit_omap_get_keys)
visitor->visit_omap_get_keys(visitor->uargs, a->start_after, a->max_return, a->iter, a->prval);
}
static void execute_read_op_visitor_on_omap_get_vals(read_op_visitor_t visitor, rd_action_omap_get_vals_t a)
{
visitor->visit_omap_get_vals(visitor->uargs, a->start_after, a->filter_prefix, a->max_return, a->iter, a->prval);
if(visitor->visit_omap_get_vals)
visitor->visit_omap_get_vals(visitor->uargs, a->start_after, a->filter_prefix, a->max_return, a->iter, a->prval);
}
static void execute_read_op_visitor_on_omap_get_vals_by_keys(read_op_visitor_t visitor, rd_action_omap_get_vals_by_keys_t a)
{
if(visitor->visit_omap_get_vals_by_keys == NULL) return;
const char* keys[a->num_keys];
unsigned i;
const char* ptr = a->data;
......
......@@ -55,46 +55,56 @@ void execute_write_op_visitor(write_op_visitor_t visitor, mobject_store_write_op
static void execute_write_op_visitor_on_create(write_op_visitor_t visitor, wr_action_create_t a)
{
visitor->visit_create(visitor->uargs, a->exclusive);
if(visitor->visit_create)
visitor->visit_create(visitor->uargs, a->exclusive);
}
static void execute_write_op_visitor_on_write(write_op_visitor_t visitor, wr_action_write_t a)
{
visitor->visit_write(visitor->uargs, a->buffer, a->len, a->offset);
if(visitor->visit_write)
visitor->visit_write(visitor->uargs, a->buffer, a->len, a->offset);
}
static void execute_write_op_visitor_on_write_full(write_op_visitor_t visitor, wr_action_write_full_t a)
{
visitor->visit_write_full(visitor->uargs, a->buffer, a->len);
if(visitor->visit_write_full)
visitor->visit_write_full(visitor->uargs, a->buffer, a->len);
}
static void execute_write_op_visitor_on_write_same(write_op_visitor_t visitor, wr_action_write_same_t a)
{
visitor->visit_writesame(visitor->uargs, a->buffer, a->data_len, a->write_len, a->offset);
if(visitor->visit_writesame)
visitor->visit_writesame(visitor->uargs, a->buffer, a->data_len, a->write_len, a->offset);
}
static void execute_write_op_visitor_on_append(write_op_visitor_t visitor, wr_action_append_t a)
{
visitor->visit_append(visitor->uargs, a->buffer, a->len);
if(visitor->visit_append)
visitor->visit_append(visitor->uargs, a->buffer, a->len);
}
static void execute_write_op_visitor_on_remove(write_op_visitor_t visitor, wr_action_remove_t a)
{
visitor->visit_remove(visitor->uargs);
if(visitor->visit_remove)
visitor->visit_remove(visitor->uargs);
}
static void execute_write_op_visitor_on_truncate(write_op_visitor_t visitor, wr_action_truncate_t a)
{
visitor->visit_truncate(visitor->uargs, a->offset);
if(visitor->visit_truncate)
visitor->visit_truncate(visitor->uargs, a->offset);
}
static void execute_write_op_visitor_on_zero(write_op_visitor_t visitor, wr_action_zero_t a)
{
visitor->visit_zero(visitor->uargs, a->offset, a->len);
if(visitor->visit_zero)
visitor->visit_zero(visitor->uargs, a->offset, a->len);
}
static void execute_write_op_visitor_on_omap_set(write_op_visitor_t visitor, wr_action_omap_set_t a)
{
if(visitor->visit_omap_set == NULL) return;
size_t num = a->num;
size_t lens[num];
const char* keys[num];
......@@ -121,6 +131,8 @@ static void execute_write_op_visitor_on_omap_set(write_op_visitor_t visitor, wr_
static void execute_write_op_visitor_on_omap_rm_keys(write_op_visitor_t visitor, wr_action_omap_rm_keys_t a)
{
if(visitor->visit_omap_rm_keys != NULL) return;
size_t num_keys = a->num_keys;
const char* keys[num_keys];
......
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