Commit c82d5789 authored by Jim Harris's avatar Jim Harris
Browse files

accel_perf: check that numeric arguments are non-negative



Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ie512181e7e0537e8319abe0a5b53492c959964d2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8491


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
parent 451462f6
Loading
Loading
Loading
Loading
+32 −9
Original line number Diff line number Diff line
@@ -162,33 +162,56 @@ usage(void)
static int
parse_args(int argc, char *argv)
{
	int argval;

	switch (argc) {
	case 'b':
	case 'C':
	case 'f':
	case 'T':
	case 'o':
	case 'P':
	case 'q':
	case 's':
	case 't':
		argval = spdk_strtol(optarg, 10);
		if (argval < 0) {
			fprintf(stderr, "-%c option must be non-negative.\n", argc);
			usage();
			return 1;
		}
		break;
	default:
		break;
	};

	switch (argc) {
	case 'b':
		g_ops_per_batch = spdk_strtol(optarg, 10);
		g_ops_per_batch = argval;
		break;
	case 'C':
		g_crc32c_chained_count = spdk_strtol(optarg, 10);
		g_crc32c_chained_count = argval;
		break;
	case 'f':
		g_fill_pattern = (uint8_t)spdk_strtol(optarg, 10);
		g_fill_pattern = (uint8_t)argval;
		break;
	case 'T':
		g_threads_per_core = spdk_strtol(optarg, 10);
		g_threads_per_core = argval;
		break;
	case 'o':
		g_xfer_size_bytes = spdk_strtol(optarg, 10);
		g_xfer_size_bytes = argval;
		break;
	case 'P':
		g_fail_percent_goal = spdk_strtol(optarg, 10);
		g_fail_percent_goal = argval;
		break;
	case 'q':
		g_queue_depth = spdk_strtol(optarg, 10);
		g_queue_depth = argval;
		break;
	case 's':
		g_crc32c_seed = spdk_strtol(optarg, 10);
		g_crc32c_seed = argval;
		break;
	case 't':
		g_time_in_sec = spdk_strtol(optarg, 10);
		g_time_in_sec = argval;
		break;
	case 'y':
		g_verify = true;