From 2fd7a8a231c8f710b7e573b761549cc130b85279 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Tue, 29 Jan 2019 11:51:00 +0900 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/c/442493 Reviewed-by: wuzhouhui Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Darek Stojaczyk Tested-by: SPDK CI Jenkins --- examples/blob/cli/blobcli.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/blob/cli/blobcli.c b/examples/blob/cli/blobcli.c index bb01e5a28..7238284e6 100644 --- a/examples/blob/cli/blobcli.c +++ b/examples/blob/cli/blobcli.c @@ -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 {