protocol/server: White space cleanup and NULL check validations.

Signed-off-by: Junaid <junaid@gluster.com>
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>

BUG: 2346 (Log message enhancements in GlusterFS - phase 1)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
This commit is contained in:
Mohammed Junaid Ahmed 2011-03-16 09:43:21 +00:00 committed by Vijay Bellur
parent 0d7628c6c2
commit d3e9a97b6e
10 changed files with 499 additions and 422 deletions

View File

@ -32,10 +32,7 @@
#include "authenticate.h" #include "authenticate.h"
static void static void
init (dict_t *this, init (dict_t *this, char *key, data_t *value, void *data)
char *key,
data_t *value,
void *data)
{ {
void *handle = NULL; void *handle = NULL;
char *auth_file = NULL; char *auth_file = NULL;
@ -60,7 +57,6 @@ init (dict_t *this,
ret = gf_asprintf (&auth_file, "%s/%s.so", LIBDIR, key); ret = gf_asprintf (&auth_file, "%s/%s.so", LIBDIR, key);
if (-1 == ret) { if (-1 == ret) {
gf_log ("authenticate", GF_LOG_ERROR, "asprintf failed");
dict_set (this, key, data_from_dynptr (NULL, 0)); dict_set (this, key, data_from_dynptr (NULL, 0));
*error = -1; *error = -1;
return; return;
@ -89,7 +85,6 @@ init (dict_t *this,
auth_handle = GF_CALLOC (1, sizeof (*auth_handle), auth_handle = GF_CALLOC (1, sizeof (*auth_handle),
gf_common_mt_auth_handle_t); gf_common_mt_auth_handle_t);
if (!auth_handle) { if (!auth_handle) {
gf_log ("authenticate", GF_LOG_ERROR, "Out of memory");
dict_set (this, key, data_from_dynptr (NULL, 0)); dict_set (this, key, data_from_dynptr (NULL, 0));
*error = -1; *error = -1;
return; return;
@ -110,10 +105,7 @@ init (dict_t *this,
} }
static void static void
fini (dict_t *this, fini (dict_t *this, char *key, data_t *value, void *data)
char *key,
data_t *value,
void *data)
{ {
auth_handle_t *handle = data_to_ptr (value); auth_handle_t *handle = data_to_ptr (value);
if (handle) { if (handle) {
@ -127,26 +119,31 @@ gf_auth_init (xlator_t *xl, dict_t *auth_modules)
int ret = 0; int ret = 0;
auth_handle_t *handle = NULL; auth_handle_t *handle = NULL;
data_pair_t *pair = NULL; data_pair_t *pair = NULL;
dict_foreach (auth_modules, init, &ret); dict_foreach (auth_modules, init, &ret);
if (!ret) { if (ret)
goto out;
pair = auth_modules->members_list; pair = auth_modules->members_list;
while (pair) { while (pair) {
handle = data_to_ptr (pair->value); handle = data_to_ptr (pair->value);
if (handle) { if (!handle) {
pair = pair->next;
continue;
}
list_add_tail (&(handle->vol_opt->list), list_add_tail (&(handle->vol_opt->list),
&(xl->volume_options)); &(xl->volume_options));
if (-1 == ret = validate_xlator_volume_options (xl,
validate_xlator_volume_options (xl, handle->vol_opt->given_opt);
handle->vol_opt->given_opt)) { if (ret)
gf_log ("authenticate", GF_LOG_ERROR, gf_log ("authenticate", GF_LOG_ERROR,
"volume option validation " "volume option validation failed");
"failed");
ret = -1;
}
}
pair = pair->next; pair = pair->next;
} }
}
out:
if (ret) { if (ret) {
gf_log (xl->name, GF_LOG_ERROR, "authentication init failed"); gf_log (xl->name, GF_LOG_ERROR, "authentication init failed");
dict_foreach (auth_modules, fini, &ret); dict_foreach (auth_modules, fini, &ret);
@ -159,10 +156,7 @@ static dict_t *__input_params;
static dict_t *__config_params; static dict_t *__config_params;
void void
map (dict_t *this, map (dict_t *this, char *key, data_t *value, void *data)
char *key,
data_t *value,
void *data)
{ {
dict_t *res = data; dict_t *res = data;
auth_fn_t authenticate; auth_fn_t authenticate;
@ -179,10 +173,7 @@ map (dict_t *this,
} }
void void
reduce (dict_t *this, reduce (dict_t *this, char *key, data_t *value, void *data)
char *key,
data_t *value,
void *data)
{ {
int64_t val = 0; int64_t val = 0;
int64_t *res = data; int64_t *res = data;
@ -212,8 +203,10 @@ gf_authenticate (dict_t *input_params,
dict_t *config_params, dict_t *config_params,
dict_t *auth_modules) dict_t *auth_modules)
{ {
char *name = NULL;
dict_t *results = NULL; dict_t *results = NULL;
int64_t result = AUTH_DONT_CARE; int64_t result = AUTH_DONT_CARE;
data_t *peerinfo_data = NULL;
results = get_new_dict (); results = get_new_dict ();
__input_params = input_params; __input_params = input_params;
@ -223,8 +216,7 @@ gf_authenticate (dict_t *input_params,
dict_foreach (results, reduce, &result); dict_foreach (results, reduce, &result);
if (AUTH_DONT_CARE == result) { if (AUTH_DONT_CARE == result) {
data_t *peerinfo_data = dict_get (input_params, "peer-info-name"); peerinfo_data = dict_get (input_params, "peer-info-name");
char *name = NULL;
if (peerinfo_data) { if (peerinfo_data) {
name = peerinfo_data->data; name = peerinfo_data->data;

View File

@ -32,8 +32,8 @@ server_decode_groups (call_frame_t *frame, rpcsvc_request_t *req)
{ {
int i = 0; int i = 0;
if ((!frame) || (!req)) GF_VALIDATE_OR_GOTO ("server", frame, out);
return 0; GF_VALIDATE_OR_GOTO ("server", req, out);
frame->root->ngrps = req->auxgidcount; frame->root->ngrps = req->auxgidcount;
if (frame->root->ngrps == 0) if (frame->root->ngrps == 0)
@ -44,7 +44,7 @@ server_decode_groups (call_frame_t *frame, rpcsvc_request_t *req)
for (; i < frame->root->ngrps; ++i) for (; i < frame->root->ngrps; ++i)
frame->root->groups[i] = req->auxgids[i]; frame->root->groups[i] = req->auxgids[i];
out:
return 0; return 0;
} }
@ -155,6 +155,11 @@ gf_add_locker (struct _lock_table *table, const char *volume,
int32_t ret = -1; int32_t ret = -1;
struct _locker *new = NULL; struct _locker *new = NULL;
GF_VALIDATE_OR_GOTO ("server", table, out);
GF_VALIDATE_OR_GOTO ("server", volume, out);
GF_VALIDATE_OR_GOTO ("server", loc, out);
GF_VALIDATE_OR_GOTO ("server", fd, out);
new = GF_CALLOC (1, sizeof (struct _locker), gf_server_mt_locker_t); new = GF_CALLOC (1, sizeof (struct _locker), gf_server_mt_locker_t);
if (new == NULL) { if (new == NULL) {
gf_log ("server", GF_LOG_ERROR, gf_log ("server", GF_LOG_ERROR,
@ -193,10 +198,15 @@ gf_del_locker (struct _lock_table *table, const char *volume,
{ {
struct _locker *locker = NULL; struct _locker *locker = NULL;
struct _locker *tmp = NULL; struct _locker *tmp = NULL;
int32_t ret = 0; int32_t ret = -1;
struct list_head *head = NULL; struct list_head *head = NULL;
struct list_head del; struct list_head del;
GF_VALIDATE_OR_GOTO ("server", table, out);
GF_VALIDATE_OR_GOTO ("server", volume, out);
GF_VALIDATE_OR_GOTO ("server", loc, out);
GF_VALIDATE_OR_GOTO ("server", fd, out);
INIT_LIST_HEAD (&del); INIT_LIST_HEAD (&del);
LOCK (&table->lock); LOCK (&table->lock);
@ -237,6 +247,8 @@ gf_del_locker (struct _lock_table *table, const char *volume,
GF_FREE (locker); GF_FREE (locker);
} }
ret = 0;
out:
return ret; return ret;
} }
@ -262,14 +274,22 @@ static int
server_nop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, server_nop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno) int32_t op_ret, int32_t op_errno)
{ {
int ret = -1;
server_state_t *state = NULL; server_state_t *state = NULL;
GF_VALIDATE_OR_GOTO ("server", frame, out);
GF_VALIDATE_OR_GOTO ("server", cookie, out);
GF_VALIDATE_OR_GOTO ("server", this, out);
state = CALL_STATE(frame); state = CALL_STATE(frame);
if (state) if (state)
free_state (state); free_state (state);
STACK_DESTROY (frame->root); STACK_DESTROY (frame->root);
return 0;
ret = 0;
out:
return ret;
} }
int int
@ -284,6 +304,11 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn,
int ret = -1; int ret = -1;
char *path = NULL; char *path = NULL;
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", conn, out);
GF_VALIDATE_OR_GOTO ("server", frame, out);
GF_VALIDATE_OR_GOTO ("server", ltable, out);
bound_xl = conn->bound_xl; bound_xl = conn->bound_xl;
INIT_LIST_HEAD (&inodelk_lockers); INIT_LIST_HEAD (&inodelk_lockers);
INIT_LIST_HEAD (&entrylk_lockers); INIT_LIST_HEAD (&entrylk_lockers);
@ -416,15 +441,23 @@ server_connection_cleanup_flush_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret, xlator_t *this, int32_t op_ret,
int32_t op_errno) int32_t op_errno)
{ {
int32_t ret = -1;
fd_t *fd = NULL; fd_t *fd = NULL;
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", cookie, out);
GF_VALIDATE_OR_GOTO ("server", frame, out);
fd = frame->local; fd = frame->local;
fd_unref (fd); fd_unref (fd);
frame->local = NULL; frame->local = NULL;
STACK_DESTROY (frame->root); STACK_DESTROY (frame->root);
return 0;
ret = 0;
out:
return ret;
} }
@ -438,6 +471,11 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame,
xlator_t *bound_xl = NULL; xlator_t *bound_xl = NULL;
char *path = NULL; char *path = NULL;
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", conn, out);
GF_VALIDATE_OR_GOTO ("server", frame, out);
GF_VALIDATE_OR_GOTO ("server", fdentries, out);
bound_xl = conn->bound_xl; bound_xl = conn->bound_xl;
for (i = 0;i < fd_count; i++) { for (i = 0;i < fd_count; i++) {
fd = fdentries[i].fd; fd = fdentries[i].fd;
@ -493,6 +531,11 @@ do_connection_cleanup (xlator_t *this, server_connection_t *conn,
call_frame_t *frame = NULL; call_frame_t *frame = NULL;
server_state_t *state = NULL; server_state_t *state = NULL;
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", conn, out);
GF_VALIDATE_OR_GOTO ("server", fdentries, out);
GF_VALIDATE_OR_GOTO ("server", ltable, out);
frame = create_frame (this, this->ctx->pool); frame = create_frame (this, this->ctx->pool);
if (frame == NULL) { if (frame == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory"); gf_log (this->name, GF_LOG_ERROR, "out of memory");
@ -529,9 +572,8 @@ server_connection_cleanup (xlator_t *this, server_connection_t *conn)
uint32_t fd_count = 0; uint32_t fd_count = 0;
int ret = 0; int ret = 0;
if (conn == NULL) { GF_VALIDATE_OR_GOTO ("server", this, out);
goto out; GF_VALIDATE_OR_GOTO ("server", conn, out);
}
pthread_mutex_lock (&conn->lock); pthread_mutex_lock (&conn->lock);
{ {
@ -577,10 +619,8 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
uint32_t fd_count = 0; uint32_t fd_count = 0;
char *path = NULL; char *path = NULL;
if (conn == NULL) { GF_VALIDATE_OR_GOTO ("server", this, out);
ret = 0; GF_VALIDATE_OR_GOTO ("server", conn, out);
goto out;
}
bound_xl = (xlator_t *) (conn->bound_xl); bound_xl = (xlator_t *) (conn->bound_xl);
@ -770,6 +810,9 @@ server_connection_get (xlator_t *this, const char *id)
server_connection_t *trav = NULL; server_connection_t *trav = NULL;
server_conf_t *conf = NULL; server_conf_t *conf = NULL;
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", id, out);
conf = this->private; conf = this->private;
pthread_mutex_lock (&conf->mutex); pthread_mutex_lock (&conf->mutex);
@ -801,7 +844,7 @@ server_connection_get (xlator_t *this, const char *id)
} }
unlock: unlock:
pthread_mutex_unlock (&conf->mutex); pthread_mutex_unlock (&conf->mutex);
out:
return conn; return conn;
} }
@ -812,15 +855,11 @@ server_connection_put (xlator_t *this, server_connection_t *conn)
server_conf_t *conf = NULL; server_conf_t *conf = NULL;
server_connection_t *todel = NULL; server_connection_t *todel = NULL;
if (conn == NULL) { GF_VALIDATE_OR_GOTO ("server", this, out);
goto out; GF_VALIDATE_OR_GOTO ("server", conn, out);
}
conf = this->private; conf = this->private;
GF_VALIDATE_OR_GOTO ("server", conf, out);
if (conf == NULL) {
goto out;
}
pthread_mutex_lock (&conf->mutex); pthread_mutex_lock (&conf->mutex);
{ {
@ -854,8 +893,7 @@ server_alloc_frame (rpcsvc_request_t *req)
GF_VALIDATE_OR_GOTO ("server", req->svc->ctx, out); GF_VALIDATE_OR_GOTO ("server", req->svc->ctx, out);
conn = (server_connection_t *)req->trans->xl_private; conn = (server_connection_t *)req->trans->xl_private;
if (!conn) GF_VALIDATE_OR_GOTO ("server", conn, out);
goto out;
frame = create_frame (conn->this, req->svc->ctx->pool); frame = create_frame (conn->this, req->svc->ctx->pool);
GF_VALIDATE_OR_GOTO ("server", frame, out); GF_VALIDATE_OR_GOTO ("server", frame, out);
@ -887,9 +925,10 @@ get_frame_from_request (rpcsvc_request_t *req)
{ {
call_frame_t *frame = NULL; call_frame_t *frame = NULL;
GF_VALIDATE_OR_GOTO ("server", req, out);
frame = server_alloc_frame (req); frame = server_alloc_frame (req);
if (!frame) GF_VALIDATE_OR_GOTO ("server", frame, out);
goto out;
frame->root->op = req->procnum; frame->root->op = req->procnum;
frame->root->type = req->type; frame->root->type = req->type;
@ -917,6 +956,9 @@ server_build_config (xlator_t *this, server_conf_t *conf)
int ret = -1; int ret = -1;
struct stat buf = {0,}; struct stat buf = {0,};
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", conf, out);
ret = dict_get_int32 (this->options, "inode-lru-limit", ret = dict_get_int32 (this->options, "inode-lru-limit",
&conf->inode_lru_limit); &conf->inode_lru_limit);
if (ret < 0) { if (ret < 0) {
@ -984,7 +1026,12 @@ out:
server_connection_t * server_connection_t *
get_server_conn_state (xlator_t *this, rpc_transport_t *xprt) get_server_conn_state (xlator_t *this, rpc_transport_t *xprt)
{ {
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", xprt, out);
return (server_connection_t *)xprt->xl_private; return (server_connection_t *)xprt->xl_private;
out:
return NULL;
} }
server_connection_t * server_connection_t *
@ -993,6 +1040,9 @@ create_server_conn_state (xlator_t *this, rpc_transport_t *xprt)
server_connection_t *conn = NULL; server_connection_t *conn = NULL;
int ret = -1; int ret = -1;
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", xprt, out);
conn = GF_CALLOC (1, sizeof (*conn), gf_server_mt_conn_t); conn = GF_CALLOC (1, sizeof (*conn), gf_server_mt_conn_t);
if (!conn) if (!conn)
goto out; goto out;
@ -1022,9 +1072,7 @@ out:
void void
destroy_server_conn_state (server_connection_t *conn) destroy_server_conn_state (server_connection_t *conn)
{ {
if (!conn) { GF_VALIDATE_OR_GOTO ("server", conn, out);
return;
}
if (conn->ltable) { if (conn->ltable) {
/* TODO */ /* TODO */
@ -1038,7 +1086,7 @@ destroy_server_conn_state (server_connection_t *conn)
pthread_mutex_destroy (&conn->lock); pthread_mutex_destroy (&conn->lock);
GF_FREE (conn); GF_FREE (conn);
out:
return; return;
} }
@ -1048,6 +1096,9 @@ print_caller (char *str, int size, call_frame_t *frame)
{ {
server_state_t *state = NULL; server_state_t *state = NULL;
GF_VALIDATE_OR_GOTO ("server", str, out);
GF_VALIDATE_OR_GOTO ("server", frame, out);
state = CALL_STATE (frame); state = CALL_STATE (frame);
snprintf (str, size, snprintf (str, size,
@ -1055,6 +1106,7 @@ print_caller (char *str, int size, call_frame_t *frame)
frame->root->unique, frame->root->unique,
state->xprt->peerinfo.identifier); state->xprt->peerinfo.identifier);
out:
return; return;
} }
@ -1064,6 +1116,8 @@ server_print_resolve (char *str, int size, server_resolve_t *resolve)
{ {
int filled = 0; int filled = 0;
GF_VALIDATE_OR_GOTO ("server", str, out);
if (!resolve) { if (!resolve) {
snprintf (str, size, "<nul>"); snprintf (str, size, "<nul>");
return; return;
@ -1091,6 +1145,8 @@ server_print_resolve (char *str, int size, server_resolve_t *resolve)
"path=%s", resolve->path); "path=%s", resolve->path);
snprintf (str + filled, size - filled, "}"); snprintf (str + filled, size - filled, "}");
out:
return;
} }
@ -1099,6 +1155,8 @@ server_print_loc (char *str, int size, loc_t *loc)
{ {
int filled = 0; int filled = 0;
GF_VALIDATE_OR_GOTO ("server", str, out);
if (!loc) { if (!loc) {
snprintf (str, size, "<nul>"); snprintf (str, size, "<nul>");
return; return;
@ -1118,6 +1176,8 @@ server_print_loc (char *str, int size, loc_t *loc)
"parent=%p", loc->parent); "parent=%p", loc->parent);
snprintf (str + filled, size - filled, "}"); snprintf (str + filled, size - filled, "}");
out:
return;
} }
@ -1126,6 +1186,8 @@ server_print_params (char *str, int size, server_state_t *state)
{ {
int filled = 0; int filled = 0;
GF_VALIDATE_OR_GOTO ("server", str, out);
filled += snprintf (str + filled, size - filled, filled += snprintf (str + filled, size - filled,
" Params={"); " Params={");
@ -1165,6 +1227,8 @@ server_print_params (char *str, int size, server_state_t *state)
snprintf (str + filled, size - filled, snprintf (str + filled, size - filled,
"bound_xl=%s}", state->conn->bound_xl->name); "bound_xl=%s}", state->conn->bound_xl->name);
out:
return;
} }
int int
@ -1201,11 +1265,13 @@ server_print_reply (call_frame_t *frame, int op_ret, int op_errno)
char fdstr[32]; char fdstr[32];
char *op = "UNKNOWN"; char *op = "UNKNOWN";
GF_VALIDATE_OR_GOTO ("server", frame, out);
this = frame->this; this = frame->this;
conf = this->private; conf = this->private;
if (!conf || !conf->trace) GF_VALIDATE_OR_GOTO ("server", conf, out);
return; GF_VALIDATE_OR_GOTO ("server", conf->trace, out);
state = CALL_STATE (frame); state = CALL_STATE (frame);
@ -1229,6 +1295,8 @@ server_print_reply (call_frame_t *frame, int op_ret, int op_errno)
gf_log (this->name, GF_LOG_NORMAL, gf_log (this->name, GF_LOG_NORMAL,
"%s%s => (%d, %d)%s", "%s%s => (%d, %d)%s",
op, caller, op_ret, op_errno, fdstr); op, caller, op_ret, op_errno, fdstr);
out:
return;
} }
@ -1246,11 +1314,13 @@ server_print_request (call_frame_t *frame)
char caller[512]; char caller[512];
char *op = "UNKNOWN"; char *op = "UNKNOWN";
GF_VALIDATE_OR_GOTO ("server", frame, out);
this = frame->this; this = frame->this;
conf = this->private; conf = this->private;
if (!conf || !conf->trace) GF_VALIDATE_OR_GOTO ("server", conf, out);
return; GF_VALIDATE_OR_GOTO ("server", conf->trace, out);
state = CALL_STATE (frame); state = CALL_STATE (frame);
@ -1290,6 +1360,8 @@ server_print_request (call_frame_t *frame)
"%s%s%s%s%s%s%s", "%s%s%s%s%s%s%s",
op, caller, op, caller,
resolve_vars, loc_vars, resolve2_vars, loc2_vars, other_vars); resolve_vars, loc_vars, resolve2_vars, loc2_vars, other_vars);
out:
return;
} }
int int
@ -1300,6 +1372,9 @@ serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp)
gfs3_dirplist *prev = NULL; gfs3_dirplist *prev = NULL;
int ret = -1; int ret = -1;
GF_VALIDATE_OR_GOTO ("server", entries, out);
GF_VALIDATE_OR_GOTO ("server", rsp, out);
list_for_each_entry (entry, &entries->list, list) { list_for_each_entry (entry, &entries->list, list) {
trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t); trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t);
if (!trav) if (!trav)
@ -1336,6 +1411,9 @@ serialize_rsp_dirent (gf_dirent_t *entries, gfs3_readdir_rsp *rsp)
gfs3_dirlist *prev = NULL; gfs3_dirlist *prev = NULL;
int ret = -1; int ret = -1;
GF_VALIDATE_OR_GOTO ("server", entries, out);
GF_VALIDATE_OR_GOTO ("server", rsp, out);
list_for_each_entry (entry, &entries->list, list) { list_for_each_entry (entry, &entries->list, list) {
trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t); trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t);
if (!trav) if (!trav)

View File

@ -61,7 +61,6 @@ prepare_components (call_frame_t *frame)
int i = 0; int i = 0;
char *trav = NULL; char *trav = NULL;
state = CALL_STATE (frame); state = CALL_STATE (frame);
resolve = state->resolve_now; resolve = state->resolve_now;
@ -71,8 +70,8 @@ prepare_components (call_frame_t *frame)
count = component_count (resolve->path); count = component_count (resolve->path);
components = GF_CALLOC (sizeof (*components), count, components = GF_CALLOC (sizeof (*components), count,
gf_server_mt_resolv_comp_t); gf_server_mt_resolv_comp_t);
if (!components) GF_VALIDATE_OR_GOTO ("server", components, out);
goto out;
resolve->components = components; resolve->components = components;
components[0].basename = ""; components[0].basename = "";

View File

@ -43,6 +43,8 @@ gfs_serialize_reply (rpcsvc_request_t *req, void *arg, gfs_serialize_t sfunc,
struct iobuf *iob = NULL; struct iobuf *iob = NULL;
ssize_t retlen = -1; ssize_t retlen = -1;
GF_VALIDATE_OR_GOTO ("server", req, ret);
/* First, get the io buffer into which the reply in arg will /* First, get the io buffer into which the reply in arg will
* be serialized. * be serialized.
*/ */
@ -93,9 +95,7 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg,
server_state_t *state = NULL; server_state_t *state = NULL;
char new_iobref = 0; char new_iobref = 0;
if (!req) { GF_VALIDATE_OR_GOTO ("server", req, ret);
goto ret;
}
if (frame) { if (frame) {
state = CALL_STATE (frame); state = CALL_STATE (frame);
@ -161,14 +161,13 @@ xdr_to_glusterfs_req (rpcsvc_request_t *req, void *arg, gfs_serialize_t sfunc)
{ {
int ret = -1; int ret = -1;
if (!req) GF_VALIDATE_OR_GOTO ("server", req, out);
return -1;
ret = sfunc (req->msg[0], arg); ret = sfunc (req->msg[0], arg);
if (ret > 0) if (ret > 0)
ret = 0; ret = 0;
out:
return ret; return ret;
} }
@ -181,8 +180,7 @@ server_fd (xlator_t *this)
int i = 1; int i = 1;
int ret = -1; int ret = -1;
if (!this) GF_VALIDATE_OR_GOTO ("server", this, out);
return -1;
conf = this->private; conf = this->private;
if (!conf) { if (!conf) {
@ -226,8 +224,9 @@ server_fd (xlator_t *this)
} }
pthread_mutex_unlock (&conf->mutex); pthread_mutex_unlock (&conf->mutex);
ret = 0;
return 0; out:
return ret;
} }
int int
@ -238,6 +237,9 @@ server_priv (xlator_t *this)
char key[GF_DUMP_MAX_BUF_LEN] = {0,}; char key[GF_DUMP_MAX_BUF_LEN] = {0,};
uint64_t total_read = 0; uint64_t total_read = 0;
uint64_t total_write = 0; uint64_t total_write = 0;
int32_t ret = -1;
GF_VALIDATE_OR_GOTO ("server", this, out);
conf = this->private; conf = this->private;
if (!conf) if (!conf)
@ -254,7 +256,9 @@ server_priv (xlator_t *this)
gf_proc_dump_build_key(key, "server", "total-bytes-write"); gf_proc_dump_build_key(key, "server", "total-bytes-write");
gf_proc_dump_write(key, "%"PRIu64, total_write); gf_proc_dump_write(key, "%"PRIu64, total_write);
return 0; ret = 0;
out:
return ret;
} }
int int
@ -266,8 +270,7 @@ server_inode (xlator_t *this)
int i = 1; int i = 1;
int ret = -1; int ret = -1;
if (!this) GF_VALIDATE_OR_GOTO ("server", this, out);
return -1;
conf = this->private; conf = this->private;
if (!conf) { if (!conf) {
@ -295,8 +298,9 @@ server_inode (xlator_t *this)
} }
pthread_mutex_unlock (&conf->mutex); pthread_mutex_unlock (&conf->mutex);
ret = 0;
return 0; out:
return ret;
} }
@ -309,6 +313,10 @@ get_auth_types (dict_t *this, char *key, data_t *value, void *data)
char *key_cpy = NULL; char *key_cpy = NULL;
int32_t ret = -1; int32_t ret = -1;
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", key, out);
GF_VALIDATE_OR_GOTO ("server", data, out);
auth_dict = data; auth_dict = data;
key_cpy = gf_strdup (key); key_cpy = gf_strdup (key);
GF_VALIDATE_OR_GOTO("server", key_cpy, out); GF_VALIDATE_OR_GOTO("server", key_cpy, out);
@ -340,11 +348,14 @@ out:
int int
validate_auth_options (xlator_t *this, dict_t *dict) validate_auth_options (xlator_t *this, dict_t *dict)
{ {
int error = 0; int error = -1;
xlator_list_t *trav = NULL; xlator_list_t *trav = NULL;
data_pair_t *pair = NULL; data_pair_t *pair = NULL;
char *tail = NULL; char *tail = NULL;
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", dict, out);
trav = this->children; trav = this->children;
while (trav) { while (trav) {
error = -1; error = -1;
@ -376,7 +387,7 @@ validate_auth_options (xlator_t *this, dict_t *dict)
} }
trav = trav->next; trav = trav->next;
} }
out:
return error; return error;
} }
@ -448,8 +459,7 @@ mem_acct_init (xlator_t *this)
{ {
int ret = -1; int ret = -1;
if (!this) GF_VALIDATE_OR_GOTO ("server", this, out);
return ret;
ret = xlator_mem_acct_init (this, gf_server_mt_end + 1); ret = xlator_mem_acct_init (this, gf_server_mt_end + 1);
@ -458,7 +468,7 @@ mem_acct_init (xlator_t *this)
"failed"); "failed");
return ret; return ret;
} }
out:
return ret; return ret;
} }
@ -635,8 +645,6 @@ reconfigure (xlator_t *this, dict_t *options)
} }
} }
out: out:
gf_log ("", GF_LOG_DEBUG, "returning %d", ret); gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
return ret; return ret;
@ -649,8 +657,7 @@ init (xlator_t *this)
server_conf_t *conf = NULL; server_conf_t *conf = NULL;
rpcsvc_listener_t *listener = NULL; rpcsvc_listener_t *listener = NULL;
if (!this) GF_VALIDATE_OR_GOTO ("init", this, out);
goto out;
if (this->children == NULL) { if (this->children == NULL) {
gf_log (this->name, GF_LOG_ERROR, gf_log (this->name, GF_LOG_ERROR,
@ -664,7 +671,9 @@ init (xlator_t *this)
goto out; goto out;
} }
conf = GF_CALLOC (1, sizeof (server_conf_t), gf_server_mt_server_conf_t); conf = GF_CALLOC (1, sizeof (server_conf_t),
gf_server_mt_server_conf_t);
GF_VALIDATE_OR_GOTO(this->name, conf, out); GF_VALIDATE_OR_GOTO(this->name, conf, out);
INIT_LIST_HEAD (&conf->conns); INIT_LIST_HEAD (&conf->conns);

View File

@ -4946,8 +4946,7 @@ server_lookup (rpcsvc_request_t *req)
gfs3_lookup_req args = {{0,},}; gfs3_lookup_req args = {{0,},};
int ret = -1; int ret = -1;
if (!req) GF_VALIDATE_OR_GOTO ("server", req, err);
return ret;
conn = req->trans->xl_private; conn = req->trans->xl_private;