Commit 35cdee26 authored by Chunyang Hui's avatar Chunyang Hui Committed by Jim Harris
Browse files

bdevperf: add check functions for input parsing



Change-Id: I71f927bb809f3465a70f0329c2c5609088ec60b4
Signed-off-by: default avatarChunyang Hui <chunyang.hui@intel.com>
Reviewed-on: https://review.gerrithub.io/c/440829


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
parent 27290f50
Loading
Loading
Loading
Loading
+37 −27
Original line number Diff line number Diff line
@@ -826,35 +826,45 @@ spdk_bdevperf_shutdown_cb(void)
static int
bdevperf_parse_arg(int ch, char *arg)
{
	long long tmp;
	char *end;

	if (ch == 'w') {
		g_workload_type = optarg;
	} 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 = atoi(optarg);
			g_queue_depth = tmp;
			break;
		case 'o':
		g_io_size = atoi(optarg);
			g_io_size = tmp;
			break;
		case 't':
		g_time_in_sec = atoi(optarg);
		break;
	case 'w':
		g_workload_type = optarg;
			g_time_in_sec = tmp;
			break;
		case 'M':
		g_rw_percentage = atoi(optarg);
			g_rw_percentage = tmp;
			g_mix_specified = true;
			break;
		case 'P':
		g_show_performance_ema_period = atoi(optarg);
			g_show_performance_ema_period = tmp;
			break;
		case 'S':
			g_show_performance_real_time = 1;
		g_show_performance_period_in_usec = atoi(optarg) * 1000000;
			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;
}