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 Keith Lucas
parent 3fe326cd77
commit e5a29595c3

View File

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