summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-04-11 03:19:25 +0000
committerAnand Avati <avati@gluster.com>2011-04-11 23:50:19 -0700
commit9ccb1e7b152ea9d27356482d51bd1946d377b799 (patch)
tree8a6970e5742aec3551b65974c54ace9b0dd3ef64 /libglusterfs
parent902478bf9e2e1fee15ef979020d28d2095211e93 (diff)
libglusterfs/src: bring in VALIDATE_OR_GOTO to args
so we can capture places which are calling these function with invalid arguments Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2346 (Log message enhancements in GlusterFS - phase 1) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/iobuf.c160
-rw-r--r--libglusterfs/src/xlator.c151
2 files changed, 183 insertions, 128 deletions
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
index 42b7f426789..c5cb9ec6607 100644
--- a/libglusterfs/src/iobuf.c
+++ b/libglusterfs/src/iobuf.c
@@ -37,6 +37,8 @@ __iobuf_arena_init_iobufs (struct iobuf_arena *iobuf_arena)
int offset = 0;
int i = 0;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_arena, out);
+
arena_size = iobuf_arena->iobuf_pool->arena_size;
page_size = iobuf_arena->iobuf_pool->page_size;
iobuf_cnt = arena_size / page_size;
@@ -61,6 +63,9 @@ __iobuf_arena_init_iobufs (struct iobuf_arena *iobuf_arena)
offset += page_size;
iobuf++;
}
+
+out:
+ return;
}
@@ -73,12 +78,14 @@ __iobuf_arena_destroy_iobufs (struct iobuf_arena *iobuf_arena)
struct iobuf *iobuf = NULL;
int i = 0;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_arena, out);
+
arena_size = iobuf_arena->iobuf_pool->arena_size;
page_size = iobuf_arena->iobuf_pool->page_size;
iobuf_cnt = arena_size / page_size;
if (!iobuf_arena->iobufs) {
- gf_log ("", GF_LOG_DEBUG, "iobufs not found");
+ gf_log_callingfn ("", GF_LOG_DEBUG, "iobufs not found");
return;
}
@@ -91,6 +98,9 @@ __iobuf_arena_destroy_iobufs (struct iobuf_arena *iobuf_arena)
}
GF_FREE (iobuf_arena->iobufs);
+
+out:
+ return;
}
@@ -99,10 +109,8 @@ __iobuf_arena_destroy (struct iobuf_arena *iobuf_arena)
{
struct iobuf_pool *iobuf_pool = NULL;
- if (!iobuf_arena) {
- gf_log ("", GF_LOG_DEBUG, "iobufs not found");
- return;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_arena, out);
+
iobuf_pool = iobuf_arena->iobuf_pool;
__iobuf_arena_destroy_iobufs (iobuf_arena);
@@ -112,6 +120,9 @@ __iobuf_arena_destroy (struct iobuf_arena *iobuf_arena)
munmap (iobuf_arena->mem_base, iobuf_pool->arena_size);
GF_FREE (iobuf_arena);
+
+out:
+ return;
}
@@ -121,6 +132,8 @@ __iobuf_arena_alloc (struct iobuf_pool *iobuf_pool)
struct iobuf_arena *iobuf_arena = NULL;
size_t arena_size = 0;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
+
iobuf_arena = GF_CALLOC (sizeof (*iobuf_arena), 1,
gf_common_mt_iobuf_arena);
if (!iobuf_arena)
@@ -151,6 +164,8 @@ __iobuf_arena_alloc (struct iobuf_pool *iobuf_pool)
err:
__iobuf_arena_destroy (iobuf_arena);
+
+out:
return NULL;
}
@@ -161,12 +176,15 @@ __iobuf_arena_unprune (struct iobuf_pool *iobuf_pool)
struct iobuf_arena *iobuf_arena = NULL;
struct iobuf_arena *tmp = NULL;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
+
list_for_each_entry (tmp, &iobuf_pool->purge.list, list) {
list_del_init (&tmp->list);
iobuf_arena = tmp;
break;
}
+out:
return iobuf_arena;
}
@@ -176,6 +194,8 @@ __iobuf_pool_add_arena (struct iobuf_pool *iobuf_pool)
{
struct iobuf_arena *iobuf_arena = NULL;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
+
iobuf_arena = __iobuf_arena_unprune (iobuf_pool);
if (!iobuf_arena)
@@ -188,6 +208,7 @@ __iobuf_pool_add_arena (struct iobuf_pool *iobuf_pool)
list_add_tail (&iobuf_arena->list, &iobuf_pool->arenas.list);
+out:
return iobuf_arena;
}
@@ -197,12 +218,15 @@ iobuf_pool_add_arena (struct iobuf_pool *iobuf_pool)
{
struct iobuf_arena *iobuf_arena = NULL;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
+
pthread_mutex_lock (&iobuf_pool->mutex);
{
iobuf_arena = __iobuf_pool_add_arena (iobuf_pool);
}
pthread_mutex_unlock (&iobuf_pool->mutex);
+out:
return iobuf_arena;
}
@@ -213,10 +237,7 @@ iobuf_pool_destroy (struct iobuf_pool *iobuf_pool)
struct iobuf_arena *iobuf_arena = NULL;
struct iobuf_arena *tmp = NULL;
- if (!iobuf_pool) {
- gf_log ("", GF_LOG_WARNING, "iobuf pool not found");
- return;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
list_for_each_entry_safe (iobuf_arena, tmp, &iobuf_pool->arenas.list,
list) {
@@ -226,6 +247,9 @@ iobuf_pool_destroy (struct iobuf_pool *iobuf_pool)
__iobuf_arena_destroy (iobuf_arena);
}
+
+out:
+ return;
}
@@ -266,6 +290,8 @@ __iobuf_pool_prune (struct iobuf_pool *iobuf_pool)
struct iobuf_arena *iobuf_arena = NULL;
struct iobuf_arena *tmp = NULL;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
+
if (list_empty (&iobuf_pool->arenas.list))
/* buffering - preserve this one arena (if at all)
for __iobuf_arena_unprune */
@@ -281,17 +307,25 @@ __iobuf_pool_prune (struct iobuf_pool *iobuf_pool)
__iobuf_arena_destroy (iobuf_arena);
}
+
+out:
+ return;
}
void
iobuf_pool_prune (struct iobuf_pool *iobuf_pool)
{
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
+
pthread_mutex_lock (&iobuf_pool->mutex);
{
__iobuf_pool_prune (iobuf_pool);
}
pthread_mutex_unlock (&iobuf_pool->mutex);
+
+out:
+ return;
}
@@ -301,6 +335,8 @@ __iobuf_select_arena (struct iobuf_pool *iobuf_pool)
struct iobuf_arena *iobuf_arena = NULL;
struct iobuf_arena *trav = NULL;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
+
/* look for unused iobuf from the head-most arena */
list_for_each_entry (trav, &iobuf_pool->arenas.list, list) {
if (trav->passive_cnt) {
@@ -314,6 +350,7 @@ __iobuf_select_arena (struct iobuf_pool *iobuf_pool)
iobuf_arena = __iobuf_pool_add_arena (iobuf_pool);
}
+out:
return iobuf_arena;
}
@@ -342,6 +379,8 @@ __iobuf_get (struct iobuf_arena *iobuf_arena)
struct iobuf *iobuf = NULL;
struct iobuf_pool *iobuf_pool = NULL;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_arena, out);
+
iobuf_pool = iobuf_arena->iobuf_pool;
list_for_each_entry (iobuf, &iobuf_arena->passive.list, list)
@@ -358,6 +397,7 @@ __iobuf_get (struct iobuf_arena *iobuf_arena)
list_add (&iobuf_arena->list, &iobuf_pool->filled.list);
}
+out:
return iobuf;
}
@@ -368,6 +408,8 @@ iobuf_get (struct iobuf_pool *iobuf_pool)
struct iobuf *iobuf = NULL;
struct iobuf_arena *iobuf_arena = NULL;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
+
pthread_mutex_lock (&iobuf_pool->mutex);
{
/* most eligible arena for picking an iobuf */
@@ -388,6 +430,7 @@ iobuf_get (struct iobuf_pool *iobuf_pool)
unlock:
pthread_mutex_unlock (&iobuf_pool->mutex);
+out:
return iobuf;
}
@@ -397,6 +440,9 @@ __iobuf_put (struct iobuf *iobuf, struct iobuf_arena *iobuf_arena)
{
struct iobuf_pool *iobuf_pool = NULL;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_arena, out);
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out);
+
iobuf_pool = iobuf_arena->iobuf_pool;
if (iobuf_arena->passive_cnt == 0) {
@@ -414,6 +460,8 @@ __iobuf_put (struct iobuf *iobuf, struct iobuf_arena *iobuf_arena)
list_del (&iobuf_arena->list);
list_add_tail (&iobuf_arena->list, &iobuf_pool->purge.list);
}
+out:
+ return;
}
@@ -423,10 +471,7 @@ iobuf_put (struct iobuf *iobuf)
struct iobuf_arena *iobuf_arena = NULL;
struct iobuf_pool *iobuf_pool = NULL;
- if (!iobuf) {
- gf_log ("", GF_LOG_WARNING, "iobuf not found");
- return;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out);
iobuf_arena = iobuf->iobuf_arena;
if (!iobuf_arena) {
@@ -447,6 +492,9 @@ iobuf_put (struct iobuf *iobuf)
pthread_mutex_unlock (&iobuf_pool->mutex);
iobuf_pool_prune (iobuf_pool);
+
+out:
+ return;
}
@@ -455,10 +503,7 @@ iobuf_unref (struct iobuf *iobuf)
{
int ref = 0;
- if (!iobuf) {
- gf_log ("", GF_LOG_WARNING, "iobuf not found");
- return;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out);
LOCK (&iobuf->lock);
{
@@ -469,16 +514,16 @@ iobuf_unref (struct iobuf *iobuf)
if (!ref)
iobuf_put (iobuf);
+
+out:
+ return;
}
struct iobuf *
iobuf_ref (struct iobuf *iobuf)
{
- if (!iobuf) {
- gf_log ("", GF_LOG_WARNING, "iobuf not found");
- return NULL;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out);
LOCK (&iobuf->lock);
{
@@ -486,6 +531,7 @@ iobuf_ref (struct iobuf *iobuf)
}
UNLOCK (&iobuf->lock);
+out:
return iobuf;
}
@@ -511,10 +557,7 @@ iobref_new ()
struct iobref *
iobref_ref (struct iobref *iobref)
{
- if (!iobref) {
- gf_log ("", GF_LOG_WARNING, "iobref not found");
- return NULL;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobref, out);
LOCK (&iobref->lock);
{
@@ -522,6 +565,7 @@ iobref_ref (struct iobref *iobref)
}
UNLOCK (&iobref->lock);
+out:
return iobref;
}
@@ -532,8 +576,7 @@ iobref_destroy (struct iobref *iobref)
int i = 0;
struct iobuf *iobuf = NULL;
- if (!iobref)
- return;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobref, out);
for (i = 0; i < 8; i++) {
iobuf = iobref->iobrefs[i];
@@ -544,6 +587,9 @@ iobref_destroy (struct iobref *iobref)
}
GF_FREE (iobref);
+
+out:
+ return;
}
@@ -552,10 +598,7 @@ iobref_unref (struct iobref *iobref)
{
int ref = 0;
- if (!iobref) {
- gf_log ("", GF_LOG_WARNING, "iobref not found");
- return;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobref, out);
LOCK (&iobref->lock);
{
@@ -565,6 +608,9 @@ iobref_unref (struct iobref *iobref)
if (!ref)
iobref_destroy (iobref);
+
+out:
+ return;
}
@@ -574,6 +620,9 @@ __iobref_add (struct iobref *iobref, struct iobuf *iobuf)
int i = 0;
int ret = -ENOMEM;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobref, out);
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out);
+
for (i = 0; i < 8; i++) {
if (iobref->iobrefs[i] == NULL) {
iobref->iobrefs[i] = iobuf_ref (iobuf);
@@ -582,6 +631,7 @@ __iobref_add (struct iobref *iobref, struct iobuf *iobuf)
}
}
+out:
return ret;
}
@@ -589,12 +639,10 @@ __iobref_add (struct iobref *iobref, struct iobuf *iobuf)
int
iobref_add (struct iobref *iobref, struct iobuf *iobuf)
{
- int ret = 0;
+ int ret = -EINVAL;
- if (!iobref || !iobuf) {
- gf_log ("", GF_LOG_WARNING, "(iobref || iobuf) not found");
- return -EINVAL;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobref, out);
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out);
LOCK (&iobref->lock);
{
@@ -602,6 +650,7 @@ iobref_add (struct iobref *iobref, struct iobuf *iobuf)
}
UNLOCK (&iobref->lock);
+out:
return ret;
}
@@ -610,9 +659,12 @@ int
iobref_merge (struct iobref *to, struct iobref *from)
{
int i = 0;
- int ret = 0;
+ int ret = -1;
struct iobuf *iobuf = NULL;
+ GF_VALIDATE_OR_GOTO ("iobuf", to, out);
+ GF_VALIDATE_OR_GOTO ("iobuf", from, out);
+
LOCK (&from->lock);
{
for (i = 0; i < 8; i++) {
@@ -629,6 +681,7 @@ iobref_merge (struct iobref *to, struct iobref *from)
}
UNLOCK (&from->lock);
+out:
return ret;
}
@@ -638,10 +691,7 @@ iobuf_size (struct iobuf *iobuf)
{
size_t size = 0;
- if (!iobuf) {
- gf_log ("", GF_LOG_WARNING, "iobuf not found");
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out);
if (!iobuf->iobuf_arena) {
gf_log ("", GF_LOG_WARNING, "arena not found");
@@ -665,10 +715,7 @@ iobref_size (struct iobref *iobref)
size_t size = 0;
int i = 0;
- if (!iobref) {
- gf_log ("", GF_LOG_WARNING, "iobref not found");
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobref, out);
LOCK (&iobref->lock);
{
@@ -678,6 +725,7 @@ iobref_size (struct iobref *iobref)
}
}
UNLOCK (&iobref->lock);
+
out:
return size;
}
@@ -689,10 +737,7 @@ iobuf_info_dump (struct iobuf *iobuf, const char *key_prefix)
struct iobuf my_iobuf;
int ret = 0;
- if (!iobuf) {
- gf_log ("", GF_LOG_WARNING, "iobuf not found");
- return;
- }
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out);
memset(&my_iobuf, 0, sizeof(my_iobuf));
@@ -710,6 +755,8 @@ iobuf_info_dump (struct iobuf *iobuf, const char *key_prefix)
gf_proc_dump_build_key(key, key_prefix,"ptr");
gf_proc_dump_write(key, "%p", my_iobuf.ptr);
+out:
+ return;
}
void
@@ -719,8 +766,7 @@ iobuf_arena_info_dump (struct iobuf_arena *iobuf_arena, const char *key_prefix)
int i = 1;
struct iobuf *trav;
- if (!iobuf_arena)
- return;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_arena, out);
gf_proc_dump_build_key(key, key_prefix,"mem_base");
gf_proc_dump_write(key, "%p", iobuf_arena->mem_base);
@@ -734,6 +780,8 @@ iobuf_arena_info_dump (struct iobuf_arena *iobuf_arena, const char *key_prefix)
iobuf_info_dump(trav, key);
}
+out:
+ return;
}
void
@@ -745,8 +793,7 @@ iobuf_stats_dump (struct iobuf_pool *iobuf_pool)
int i = 1;
int ret = -1;
- if (!iobuf_pool)
- return;
+ GF_VALIDATE_OR_GOTO ("iobuf", iobuf_pool, out);
memset(msg, 0, sizeof(msg));
@@ -776,6 +823,7 @@ iobuf_stats_dump (struct iobuf_pool *iobuf_pool)
pthread_mutex_unlock(&iobuf_pool->mutex);
+out:
return;
}
@@ -783,6 +831,12 @@ iobuf_stats_dump (struct iobuf_pool *iobuf_pool)
void
iobuf_to_iovec(struct iobuf *iob, struct iovec *iov)
{
+ GF_VALIDATE_OR_GOTO ("iobuf", iob, out);
+ GF_VALIDATE_OR_GOTO ("iobuf", iov, out);
+
iov->iov_base = iobuf_ptr (iob);
iov->iov_len = iobuf_pagesize (iob);
+
+out:
+ return;
}
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index bb95e43a280..b8f800c7050 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -1159,70 +1159,68 @@ validate_xlator_volume_options (xlator_t *xl, volume_option_t *opt)
int32_t
xlator_set_type_virtual (xlator_t *xl, const char *type)
{
- if ((xl == NULL) || (type == NULL)) {
- gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("xlator", xl, out);
+ GF_VALIDATE_OR_GOTO ("xlator", type, out);
xl->type = gf_strdup (type);
if (xl->type)
return 0;
- else
- return -1;
+
+out:
+ return -1;
}
int32_t
xlator_dynload (xlator_t *xl)
{
- int ret = 0;
+ int ret = -1;
char *name = NULL;
void *handle = NULL;
volume_opt_list_t *vol_opt = NULL;
+ GF_VALIDATE_OR_GOTO ("xlator", xl, out);
+
ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xl->type);
if (-1 == ret) {
gf_log ("xlator", GF_LOG_ERROR, "asprintf failed");
- return -1;
+ goto out;
}
+ ret = -1;
+
gf_log ("xlator", GF_LOG_TRACE, "attempt to load file %s", name);
handle = dlopen (name, RTLD_NOW|RTLD_GLOBAL);
if (!handle) {
gf_log ("xlator", GF_LOG_WARNING, "%s", dlerror ());
- GF_FREE (name);
- return -1;
+ goto out;
}
xl->dlhandle = handle;
if (!(xl->fops = dlsym (handle, "fops"))) {
gf_log ("xlator", GF_LOG_WARNING, "dlsym(fops) on %s",
dlerror ());
- GF_FREE (name);
- return -1;
+ goto out;
}
if (!(xl->cbks = dlsym (handle, "cbks"))) {
gf_log ("xlator", GF_LOG_WARNING, "dlsym(cbks) on %s",
dlerror ());
- GF_FREE (name);
- return -1;
+ goto out;
}
if (!(xl->init = dlsym (handle, "init"))) {
gf_log ("xlator", GF_LOG_WARNING, "dlsym(init) on %s",
dlerror ());
- GF_FREE (name);
- return -1;
+ goto out;
}
if (!(xl->fini = dlsym (handle, "fini"))) {
gf_log ("xlator", GF_LOG_WARNING, "dlsym(fini) on %s",
dlerror ());
- GF_FREE (name);
- return -1;
+ goto out;
}
if (!(xl->notify = dlsym (handle, "notify"))) {
@@ -1260,8 +1258,7 @@ xlator_dynload (xlator_t *xl)
gf_common_mt_volume_opt_list_t);
if (!vol_opt) {
- GF_FREE (name);
- return -1;
+ goto out;
}
if (!(vol_opt->given_opt = dlsym (handle, "options"))) {
@@ -1273,8 +1270,12 @@ xlator_dynload (xlator_t *xl)
fill_defaults (xl);
- GF_FREE (name);
- return 0;
+ ret = 0;
+
+out:
+ if (name)
+ GF_FREE (name);
+ return ret;
}
@@ -1300,10 +1301,9 @@ xlator_foreach (xlator_t *this,
xlator_t *first = NULL;
xlator_t *old_THIS = NULL;
- if ((this == NULL) || (fn == NULL) || (data == NULL)) {
- gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
- return;
- }
+ GF_VALIDATE_OR_GOTO ("xlator", this, out);
+ GF_VALIDATE_OR_GOTO ("xlator", fn, out);
+ GF_VALIDATE_OR_GOTO ("xlator", data, out);
first = this;
@@ -1319,6 +1319,9 @@ xlator_foreach (xlator_t *this,
THIS = old_THIS;
first = first->next;
}
+
+out:
+ return;
}
@@ -1327,10 +1330,8 @@ xlator_search_by_name (xlator_t *any, const char *name)
{
xlator_t *search = NULL;
- if ((any == NULL) || (name == NULL)) {
- gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
- return NULL;
- }
+ GF_VALIDATE_OR_GOTO ("xlator", any, out);
+ GF_VALIDATE_OR_GOTO ("xlator", name, out);
search = any;
@@ -1343,6 +1344,7 @@ xlator_search_by_name (xlator_t *any, const char *name)
search = search->next;
}
+out:
return search;
}
@@ -1367,14 +1369,9 @@ __xlator_init(xlator_t *xl)
int
xlator_init (xlator_t *xl)
{
- int32_t ret = 0;
+ int32_t ret = -1;
- if (xl == NULL) {
- gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
- return 0;
- }
-
- ret = -1;
+ GF_VALIDATE_OR_GOTO ("xlator", xl, out);
if (xl->mem_acct_init)
xl->mem_acct_init (xl);
@@ -1408,10 +1405,7 @@ xlator_fini_rec (xlator_t *xl)
xlator_list_t *trav = NULL;
xlator_t *old_THIS = NULL;
- if (xl == NULL) {
- gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
- return;
- }
+ GF_VALIDATE_OR_GOTO ("xlator", xl, out);
trav = xl->children;
@@ -1438,6 +1432,9 @@ xlator_fini_rec (xlator_t *xl)
}
xl->init_succeeded = 0;
}
+
+out:
+ return;
}
static int
@@ -1445,13 +1442,11 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl)
{
xlator_list_t *trav1 = NULL;
xlator_list_t *trav2 = NULL;
- int32_t ret = 0;
+ int32_t ret = -1;
xlator_t *old_THIS = NULL;
- if ((old_xl == NULL) || (new_xl == NULL)) {
- gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("xlator", old_xl, out);
+ GF_VALIDATE_OR_GOTO ("xlator", new_xl, out);
trav1 = old_xl->children;
trav2 = new_xl->children;
@@ -1481,6 +1476,7 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl)
gf_log (old_xl->name, GF_LOG_DEBUG, "No reconfigure() found");
}
+ ret = 0;
out:
return ret;
}
@@ -1488,19 +1484,17 @@ out:
int
xlator_validate_rec (xlator_t *xlator, char **op_errstr)
{
+ int ret = -1;
xlator_list_t *trav = NULL;
- if (xlator == NULL ) {
- gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("xlator", xlator, out);
trav = xlator->children;
while (trav) {
if (xlator_validate_rec (trav->xlator, op_errstr)) {
gf_log ("xlator", GF_LOG_WARNING, "validate_rec failed");
- return -1;
+ goto out;
}
trav = trav->next;
@@ -1511,8 +1505,8 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr)
if (xlator->validate_options) {
if (xlator->validate_options (xlator, op_errstr)) {
- gf_log ("", GF_LOG_DEBUG, "%s", *op_errstr);
- return -1;
+ gf_log ("", GF_LOG_INFO, "%s", *op_errstr);
+ goto out;
}
gf_log (xlator->name, GF_LOG_DEBUG, "Validated option");
@@ -1520,7 +1514,9 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr)
gf_log (xlator->name, GF_LOG_DEBUG, "No validate_options() found");
- return 0;
+ ret = 0;
+out:
+ return ret;
}
int
@@ -1590,13 +1586,13 @@ xlator_tree_fini (xlator_t *xl)
{
xlator_t *top = NULL;
- if (xl == NULL) {
- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
- return;
- }
+ GF_VALIDATE_OR_GOTO ("xlator", xl, out);
top = xl;
xlator_fini_rec (top);
+
+out:
+ return;
}
int
@@ -1618,23 +1614,23 @@ xlator_tree_reconfigure (xlator_t *old_xl, xlator_t *new_xl)
int
xlator_tree_free (xlator_t *tree)
{
- xlator_t *trav = tree, *prev = tree;
-
- if (!tree) {
- gf_log ("parser", GF_LOG_ERROR, "Translator tree not found");
- return -1;
- }
-
- while (prev) {
- trav = prev->next;
- dict_destroy (prev->options);
- GF_FREE (prev->name);
- GF_FREE (prev->type);
- GF_FREE (prev);
- prev = trav;
- }
-
- return 0;
+ xlator_t *trav = tree, *prev = tree;
+
+ if (!tree) {
+ gf_log ("parser", GF_LOG_ERROR, "Translator tree not found");
+ return -1;
+ }
+
+ while (prev) {
+ trav = prev->next;
+ dict_destroy (prev->options);
+ GF_FREE (prev->name);
+ GF_FREE (prev->type);
+ GF_FREE (prev);
+ prev = trav;
+ }
+
+ return 0;
}
@@ -1662,6 +1658,9 @@ loc_copy (loc_t *dst, loc_t *src)
{
int ret = -1;
+ GF_VALIDATE_OR_GOTO ("xlator", dst, err);
+ GF_VALIDATE_OR_GOTO ("xlator", src, err);
+
dst->ino = src->ino;
if (src->inode)
@@ -1688,6 +1687,8 @@ out:
if (dst->parent)
inode_unref (dst->parent);
}
+
+err:
return ret;
}