examples/blob: Replace atoll by spdk_strtoll

atoll also doesn't have error check. Hence replace atoll by spdk_strtoll.

Drop in replacement of atoll by spdk_strtoll doesn't have error check
but current use cases of atoll are for ID and spdk_strtoll returns
explicit error code instead of zero. Hence this change is better than
nothing and will make possible for SPDK to ban not only atoi but also atol
and atoll.

Future patches may add additional error check if necessary.

Change-Id: I047e89bc9053d9f19831711da032be99cdecfaa7
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/442493
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-01-29 11:51:00 +09:00 committed by Darek Stojaczyk
parent ca558b6163
commit 2fd7a8a231

View File

@ -1070,7 +1070,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
if (argv[optind] != NULL) {
cmd_chosen++;
cli_context->action = CLI_DUMP_BLOB;
cli_context->blobid = atoll(optarg);
cli_context->blobid = spdk_strtoll(optarg, 10);
snprintf(cli_context->file, BUFSIZE, "%s", argv[optind]);
} else {
usage(cli_context, "ERROR: missing parameter.\n");
@ -1080,7 +1080,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
if (argv[optind] != NULL) {
cmd_chosen++;
cli_context->action = CLI_FILL;
cli_context->blobid = atoll(optarg);
cli_context->blobid = spdk_strtoll(optarg, 10);
cli_context->fill_value = spdk_strtol(argv[optind], 10);
} else {
usage(cli_context, "ERROR: missing parameter.\n");
@ -1113,7 +1113,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
if (argv[optind] != NULL) {
cmd_chosen++;
cli_context->action = CLI_REM_XATTR;
cli_context->blobid = atoll(optarg);
cli_context->blobid = spdk_strtoll(optarg, 10);
snprintf(cli_context->key, BUFSIZE, "%s", argv[optind]);
} else {
usage(cli_context, "ERROR: missing parameter.\n");
@ -1134,7 +1134,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
if (argv[optind] != NULL) {
cmd_chosen++;
cli_context->action = CLI_IMPORT_BLOB;
cli_context->blobid = atoll(optarg);
cli_context->blobid = spdk_strtoll(optarg, 10);
snprintf(cli_context->file, BUFSIZE, "%s", argv[optind]);
} else {
usage(cli_context, "ERROR: missing parameter.\n");
@ -1152,7 +1152,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
case 'p':
cmd_chosen++;
cli_context->action = CLI_SET_SUPER;
cli_context->superid = atoll(optarg);
cli_context->superid = spdk_strtoll(optarg, 10);
break;
case 'S':
if (cli_context->cli_mode == CLI_MODE_CMD) {
@ -1167,7 +1167,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
cli_context->action = CLI_SHOW_BS;
} else {
cli_context->action = CLI_SHOW_BLOB;
cli_context->blobid = atoll(optarg);
cli_context->blobid = spdk_strtoll(optarg, 10);
}
break;
case 'T':
@ -1192,7 +1192,7 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
if (argv[optind] != NULL || argv[optind + 1] != NULL) {
cmd_chosen++;
cli_context->action = CLI_SET_XATTR;
cli_context->blobid = atoll(optarg);
cli_context->blobid = spdk_strtoll(optarg, 10);
snprintf(cli_context->key, BUFSIZE, "%s", argv[optind]);
snprintf(cli_context->value, BUFSIZE, "%s", argv[optind + 1]);
} else {