bdevperf: add check functions for input parsing

Change-Id: I71f927bb809f3465a70f0329c2c5609088ec60b4
Signed-off-by: Chunyang Hui <chunyang.hui@intel.com>
Reviewed-on: https://review.gerrithub.io/c/440829
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Chunyang Hui 2019-01-17 09:05:53 -05:00 committed by Jim Harris
parent 27290f500d
commit 35cdee26ad

View File

@ -826,34 +826,44 @@ spdk_bdevperf_shutdown_cb(void)
static int static int
bdevperf_parse_arg(int ch, char *arg) bdevperf_parse_arg(int ch, char *arg)
{ {
switch (ch) { long long tmp;
case 'q': char *end;
g_queue_depth = atoi(optarg);
break; if (ch == 'w') {
case 'o':
g_io_size = atoi(optarg);
break;
case 't':
g_time_in_sec = atoi(optarg);
break;
case 'w':
g_workload_type = optarg; g_workload_type = optarg;
break; } else {
case 'M': tmp = strtoll(optarg, &end, 10);
g_rw_percentage = atoi(optarg); if (tmp <= INT_MIN || tmp >= INT_MAX) {
g_mix_specified = true; fprintf(stderr, "-%c out of range. Parse failed\n", ch);
break; return -ERANGE;
case 'P': }
g_show_performance_ema_period = atoi(optarg);
break; switch (ch) {
case 'S': case 'q':
g_show_performance_real_time = 1; g_queue_depth = tmp;
g_show_performance_period_in_usec = atoi(optarg) * 1000000; break;
g_show_performance_period_in_usec = spdk_max(g_show_performance_period_in_usec, case 'o':
g_show_performance_period_in_usec); g_io_size = tmp;
break; break;
default: case 't':
return -EINVAL; g_time_in_sec = tmp;
break;
case 'M':
g_rw_percentage = tmp;
g_mix_specified = true;
break;
case 'P':
g_show_performance_ema_period = tmp;
break;
case 'S':
g_show_performance_real_time = 1;
g_show_performance_period_in_usec = tmp * 1000000;
g_show_performance_period_in_usec = spdk_max(g_show_performance_period_in_usec,
g_show_performance_period_in_usec);
break;
default:
return -EINVAL;
}
} }
return 0; return 0;
} }