diff options
author | Sanju Rakonde <srakonde@redhat.com> | 2018-09-23 16:42:54 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-10-01 08:02:27 +0000 |
commit | f054b511057ada37790bfb518c70d6631ed11d93 (patch) | |
tree | 742e05b9273bcc6b920a5aa7cabdf5542580e13d /cli/src/cli-cmd-system.c | |
parent | 1c0facf59a85b1256a52e7a99b30743283a4c9cf (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-system.c')
-rw-r--r-- | cli/src/cli-cmd-system.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c index 96b229582fb..46ff926a2b8 100644 --- a/cli/src/cli-cmd-system.c +++ b/cli/src/cli-cmd-system.c @@ -264,8 +264,11 @@ cli_cmd_umount_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_UMOUNT]; if (proc && proc->fn) { 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 = proc->fn(frame, THIS, dict); } @@ -501,8 +504,11 @@ cli_cmd_sys_exec_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SYS_EXEC]; if (proc->fn) { 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); ret = proc->fn(frame, THIS, (void *)dict); @@ -559,8 +565,11 @@ cli_cmd_copy_file_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_COPY_FILE]; if (proc && proc->fn) { 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); ret = proc->fn(frame, THIS, (void *)dict); } |