Commit 404c5a3f authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

blobcli: Improve error check of input parsing by spdk_strtol



It looks that each call of atoi expects atoi returns negative
for any error. spdk_strtol will satisfy this requirement.

Change-Id: Ic21817499ed280ef4b26809ab311f337c2636470
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/441627


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarwuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent b78e763c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1081,7 +1081,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
				cmd_chosen++;
				cli_context->action = CLI_FILL;
				cli_context->blobid = atoll(optarg);
				cli_context->fill_value = atoi(argv[optind]);
				cli_context->fill_value = spdk_strtol(argv[optind], 10);
			} else {
				usage(cli_context, "ERROR: missing parameter.\n");
			}
@@ -1141,7 +1141,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
			}
			break;
		case 'n':
			cli_context->num_clusters = atoi(optarg);
			cli_context->num_clusters = spdk_strtol(optarg, 10);
			if (cli_context->num_clusters > 0) {
				cmd_chosen++;
				cli_context->action = CLI_CREATE_BLOB;
@@ -1251,7 +1251,7 @@ line_parser(struct cli_context_t *cli_context)
		cli_context->argv[cli_context->argc] = strdup(tok);
		if (tok[0] == '$' && tok[1] == 'B') {
			tok += 2;
			blob_num = atoi(tok);
			blob_num = spdk_strtol(tok, 10);
			if (blob_num >= 0 && blob_num < MAX_SCRIPT_BLOBS) {
				cli_context->argv[cli_context->argc] =
					realloc(cli_context->argv[cli_context->argc], BUFSIZE);