From f054b511057ada37790bfb518c70d6631ed11d93 Mon Sep 17 00:00:00 2001 From: Sanju Rakonde Date: Sun, 23 Sep 2018 16:42:54 +0530 Subject: 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 --- cli/src/cli-cmd-system.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'cli/src/cli-cmd-system.c') 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); } -- cgit