hotplug.c: add a second switch to parse_args()

Add another level of option parsing to allow usage
of string values.
Currently all values are converted to long
(or have to be checked before the switch),
which results in errors upon adding a string as a value.

This is going to be used in the next patch in the series.

Change-Id: Ib874d74b015eee825b5135ef3d49b9cb1c72029b
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10471
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Krzysztof Karas 2021-11-30 13:27:36 +00:00 committed by Tomasz Zawadzki
parent 1b81d438bb
commit eb48f76d61

View File

@ -444,31 +444,37 @@ parse_args(int argc, char **argv)
return 1;
}
if (op == 'm') {
g_iova_mode = optarg;
continue;
}
val = spdk_strtol(optarg, 10);
if (val < 0) {
fprintf(stderr, "Converting a string to integer failed\n");
return val;
}
switch (op) {
case 'c':
g_timeout_in_us = val * SPDK_SEC_TO_USEC;
break;
case 'i':
g_shm_id = val;
break;
case 'n':
g_expected_insert_times = val;
break;
case 'r':
g_expected_removal_times = val;
break;
case 't':
g_time_in_sec = val;
val = spdk_strtol(optarg, 10);
if (val < 0) {
fprintf(stderr, "Converting a string to integer failed\n");
return val;
}
switch (op) {
case 'c':
g_timeout_in_us = val * SPDK_SEC_TO_USEC;
break;
case 'i':
g_shm_id = val;
break;
case 'n':
g_expected_insert_times = val;
break;
case 'r':
g_expected_removal_times = val;
break;
case 't':
g_time_in_sec = val;
break;
}
break;
case 'm':
g_iova_mode = optarg;
break;
default:
usage(argv[0]);