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:
parent
27290f500d
commit
35cdee26ad
@ -826,34 +826,44 @@ spdk_bdevperf_shutdown_cb(void)
|
||||
static int
|
||||
bdevperf_parse_arg(int ch, char *arg)
|
||||
{
|
||||
switch (ch) {
|
||||
case 'q':
|
||||
g_queue_depth = atoi(optarg);
|
||||
break;
|
||||
case 'o':
|
||||
g_io_size = atoi(optarg);
|
||||
break;
|
||||
case 't':
|
||||
g_time_in_sec = atoi(optarg);
|
||||
break;
|
||||
case 'w':
|
||||
long long tmp;
|
||||
char *end;
|
||||
|
||||
if (ch == 'w') {
|
||||
g_workload_type = optarg;
|
||||
break;
|
||||
case 'M':
|
||||
g_rw_percentage = atoi(optarg);
|
||||
g_mix_specified = true;
|
||||
break;
|
||||
case 'P':
|
||||
g_show_performance_ema_period = atoi(optarg);
|
||||
break;
|
||||
case 'S':
|
||||
g_show_performance_real_time = 1;
|
||||
g_show_performance_period_in_usec = atoi(optarg) * 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;
|
||||
} else {
|
||||
tmp = strtoll(optarg, &end, 10);
|
||||
if (tmp <= INT_MIN || tmp >= INT_MAX) {
|
||||
fprintf(stderr, "-%c out of range. Parse failed\n", ch);
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
switch (ch) {
|
||||
case 'q':
|
||||
g_queue_depth = tmp;
|
||||
break;
|
||||
case 'o':
|
||||
g_io_size = tmp;
|
||||
break;
|
||||
case 't':
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user