examples/sock: Improve error check of input parsing by spdk_strtol

Change-Id: I2757d83344e6a3b78b18b3d3678776e84dc26614
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/441637
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-01-23 10:01:26 +09:00 committed by Darek Stojaczyk
parent 0f9dc2af87
commit 67b720f451

View File

@ -98,7 +98,11 @@ static int hello_sock_parse_arg(int ch, char *arg)
g_host = arg;
break;
case 'P':
g_port = atoi(arg);
g_port = spdk_strtol(arg, 10);
if (g_port < 0) {
fprintf(stderr, "Invalid port ID\n");
return g_port;
}
break;
case 'S':
g_is_server = 1;