summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-volume.c
diff options
context:
space:
mode:
authorSanju Rakonde <srakonde@redhat.com>2018-09-23 16:42:54 +0530
committerAmar Tumballi <amarts@redhat.com>2018-10-01 08:02:27 +0000
commitf054b511057ada37790bfb518c70d6631ed11d93 (patch)
tree742e05b9273bcc6b920a5aa7cabdf5542580e13d /cli/src/cli-cmd-volume.c
parent1c0facf59a85b1256a52e7a99b30743283a4c9cf (diff)
cli: handle negative scenarios
When control flow reaches negative case code block, we added "goto out" statement without assigning ret to -1. This patch assigns return value to -1, before going to the lable "out". Change-Id: I6db651a3c9ca285ade9ee1ca23d0abe6b36fda3a updates: bz#1193929 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
-rw-r--r--cli/src/cli-cmd-volume.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index ab17729d182..af2cccca23c 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -177,8 +177,11 @@ cli_cmd_sync_volume_cbk(struct cli_state *state, struct cli_cmd_word *word,
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SYNC_VOLUME];
frame = create_frame(THIS, THIS->ctx->pool);
- if (!frame)
+ if (!frame) {
+ gf_log(THIS->name, GF_LOG_ERROR, "failed to create frame");
+ ret = -1;
goto out;
+ }
CLI_LOCAL_INIT(local, words, frame, dict);
@@ -763,8 +766,11 @@ cli_cmd_volume_profile_cbk(struct cli_state *state, struct cli_cmd_word *word,
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_PROFILE_VOLUME];
frame = create_frame(THIS, THIS->ctx->pool);
- if (!frame)
+ if (!frame) {
+ gf_log(THIS->name, GF_LOG_ERROR, "failed to create frame");
+ ret = -1;
goto out;
+ }
CLI_LOCAL_INIT(local, words, frame, options);
@@ -960,6 +966,10 @@ cli_event_remove_brick_str(dict_t *options, char **event_str,
bricklist = GF_CALLOC(eventstrlen, sizeof(char), gf_common_mt_char);
if (!bricklist) {
+ gf_log(THIS->name, GF_LOG_ERROR,
+ "memory allocation failed for"
+ "bricklist");
+ ret = -1;
goto out;
}
@@ -1392,8 +1402,11 @@ cli_cmd_volume_tier_cbk(struct cli_state *state, struct cli_cmd_word *word,
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_TIER];
frame = create_frame(THIS, THIS->ctx->pool);
- if (!frame)
+ if (!frame) {
+ gf_log(THIS->name, GF_LOG_ERROR, "failed to create frame");
+ ret = -1;
goto out;
+ }
CLI_LOCAL_INIT(local, words, frame, options);
@@ -2289,8 +2302,11 @@ cli_cmd_volume_top_cbk(struct cli_state *state, struct cli_cmd_word *word,
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_TOP_VOLUME];
frame = create_frame(THIS, THIS->ctx->pool);
- if (!frame)
+ if (!frame) {
+ gf_log(THIS->name, GF_LOG_ERROR, "failed to create frame");
+ ret = -1;
goto out;
+ }
CLI_LOCAL_INIT(local, words, frame, options);
@@ -2338,8 +2354,11 @@ cli_cmd_log_rotate_cbk(struct cli_state *state, struct cli_cmd_word *word,
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LOG_ROTATE];
frame = create_frame(THIS, THIS->ctx->pool);
- if (!frame)
+ if (!frame) {
+ gf_log(THIS->name, GF_LOG_ERROR, "failed to create frame");
+ ret = -1;
goto out;
+ }
ret = cli_cmd_log_rotate_parse(words, wordcount, &options);
if (ret)
@@ -2608,12 +2627,17 @@ cli_cmd_volume_status_cbk(struct cli_state *state, struct cli_cmd_word *word,
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STATUS_ALL];
}
- if (!proc->fn)
+ if (!proc->fn) {
+ ret = -1;
goto out;
+ }
frame = create_frame(THIS, THIS->ctx->pool);
- if (!frame)
+ if (!frame) {
+ gf_log(THIS->name, GF_LOG_ERROR, "failed to create frame");
+ ret = -1;
goto out;
+ }
CLI_LOCAL_INIT(local, words, frame, dict);
@@ -3374,7 +3398,7 @@ struct cli_cmd volume_cmds[] = {
#if (SYNCDAEMON_COMPILE)
{"volume " GEOREP " [<VOLNAME>] [<SLAVE-URL>] {create [[ssh-port n] "
- "[[no-verify]|[push-pem]]] [force]"
+ "[[no-verify]|[push-pem]]] [force]"
"|start [force]|stop [force]|pause [force]|resume [force]|config|status "
"[detail]|delete [reset-sync-time]} [options...]",
cli_cmd_volume_gsync_set_cbk, "Geo-sync operations",