diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 20 | ||||
-rw-r--r-- | cli/src/cli-cmd-system.c | 15 | ||||
-rw-r--r-- | cli/src/cli-cmd-volume.c | 40 | ||||
-rw-r--r-- | cli/src/cli-rpc-ops.c | 21 |
4 files changed, 79 insertions, 17 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 3f9056b5d9e..ceb95af785d 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1483,6 +1483,8 @@ cli_add_key_group_value(dict_t *dict, const char *name, const char *value, } data = gf_strdup(value); if (data == NULL) { + gf_log(THIS->name, GF_LOG_ERROR, "Failed to allocate memory for data"); + ret = -1; goto out; } @@ -3080,8 +3082,10 @@ cli_cmd_gsync_set_parse(const char **words, int wordcount, dict_t **options) cmdi++; } - if (type != GF_GSYNC_OPTION_TYPE_CONFIG && (cmdi < wordcount - 1 || glob)) + if (type != GF_GSYNC_OPTION_TYPE_CONFIG && (cmdi < wordcount - 1 || glob)) { + ret = -1; goto out; + } /* If got so far, input is valid, assemble the message */ @@ -3162,11 +3166,15 @@ cli_cmd_volume_profile_parse(const char **words, int wordcount, goto out; } - if ((strcmp(w, "start") == 0 || strcmp(w, "stop") == 0) && wordcount > 5) + if ((strcmp(w, "start") == 0 || strcmp(w, "stop") == 0) && wordcount > 5) { + ret = -1; goto out; + } - if (strcmp(w, "info") == 0 && wordcount > 7) + if (strcmp(w, "info") == 0 && wordcount > 7) { + ret = -1; goto out; + } if (strcmp(w, "start") == 0) { op = GF_CLI_STATS_START; @@ -3965,8 +3973,11 @@ cli_cmd_volume_heal_options_parse(const char **words, int wordcount, gf_xl_afr_op_t op = GF_SHD_OP_INVALID; dict = dict_new(); - if (!dict) + if (!dict) { + gf_log(THIS->name, GF_LOG_ERROR, "Failed to create the dict"); + ret = -1; goto out; + } ret = dict_set_str(dict, "volname", (char *)words[2]); if (ret) { @@ -5591,6 +5602,7 @@ cli_cmd_snapshot_parse(const char **words, int wordcount, dict_t **options, break; default: + ret = -1; gf_log("", GF_LOG_ERROR, "Opword Mismatch"); goto out; } 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); } 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", diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 4c952b5ccb7..850658b2a2e 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -3989,6 +3989,7 @@ cli_quotad_getlimit_cbk(struct rpc_req *req, struct iovec *iov, int count, if (node == NULL) { gf_log("cli", GF_LOG_ERROR, "failed to add node to the list"); dict_unref(dict); + ret = -1; goto out; } } @@ -4270,6 +4271,7 @@ gf_cli_getspec_cbk(struct rpc_req *req, struct iovec *iov, int count, if (rsp.op_ret == -1) { gf_log(((call_frame_t *)myframe)->this->name, GF_LOG_ERROR, "getspec failed"); + ret = -1; goto out; } @@ -4278,6 +4280,7 @@ gf_cli_getspec_cbk(struct rpc_req *req, struct iovec *iov, int count, spec = GF_MALLOC(rsp.op_ret + 1, cli_mt_char); if (!spec) { gf_log("", GF_LOG_ERROR, "out of memory"); + ret = -1; goto out; } memcpy(spec, rsp.spec, rsp.op_ret); @@ -4318,6 +4321,7 @@ gf_cli_pmap_b2p_cbk(struct rpc_req *req, struct iovec *iov, int count, if (rsp.op_ret == -1) { gf_log(((call_frame_t *)myframe)->this->name, GF_LOG_ERROR, "pump_b2p failed"); + ret = -1; goto out; } @@ -4551,8 +4555,11 @@ gf_cli_get_volume(call_frame_t *frame, xlator_t *this, void *data) ctx = data; dict = dict_new(); - if (!dict) + if (!dict) { + gf_log(THIS->name, GF_LOG_ERROR, "Failed to create the dict"); + ret = -1; goto out; + } if (ctx->volname) { ret = dict_set_str(dict, "volname", ctx->volname); @@ -8220,8 +8227,11 @@ gf_cli_status_cbk(struct rpc_req *req, struct iovec *iov, int count, } dict = dict_new(); - if (!dict) + if (!dict) { + gf_log(THIS->name, GF_LOG_ERROR, "Failed to create the dict"); + ret = -1; goto out; + } ret = dict_unserialize(rsp.dict.dict_val, rsp.dict.dict_len, &dict); if (ret) @@ -9089,6 +9099,7 @@ gf_cli_heal_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, if (!brick_count) { cli_err("All bricks of volume %s are down.", volname); + ret = -1; goto out; } @@ -10518,11 +10529,13 @@ gf_cli_generate_snapshot_event(gf_cli_rsp *rsp, dict_t *dict, int32_t type, } if (!snap_uuid) { + ret = -1; gf_log("cli", GF_LOG_ERROR, "Failed to get snap uuid"); goto out; } if (!volname) { + ret = -1; gf_log("cli", GF_LOG_ERROR, "Failed to get volname"); goto out; } @@ -10566,6 +10579,7 @@ gf_cli_generate_snapshot_event(gf_cli_rsp *rsp, dict_t *dict, int32_t type, } if (!snap_uuid) { + ret = -1; gf_log("cli", GF_LOG_ERROR, "Failed to get snap uuid"); goto out; } @@ -10601,6 +10615,7 @@ gf_cli_generate_snapshot_event(gf_cli_rsp *rsp, dict_t *dict, int32_t type, } if (!snap_uuid) { + ret = -1; gf_log("cli", GF_LOG_ERROR, "Failed to get snap uuid"); goto out; } @@ -10826,11 +10841,13 @@ gf_cli_snapshot_cbk(struct rpc_req *req, struct iovec *iov, int count, } if (!snap_name) { + ret = -1; gf_log("cli", GF_LOG_ERROR, "Failed to get snap name"); goto out; } if (!volname) { + ret = -1; gf_log("cli", GF_LOG_ERROR, "Failed to get volume name"); goto out; } |