|
27 | 27 | #include <stdlib.h> |
28 | 28 | #include <stdio.h> |
29 | 29 | #include <string.h> |
| 30 | +#include <sys/param.h> |
30 | 31 | #include <sys/socket.h> |
31 | 32 | #include <unistd.h> |
32 | 33 |
|
@@ -114,7 +115,7 @@ static int safe_recv(int s, char *buf, size_t len, int flags) |
114 | 115 | ****************************************************************************/ |
115 | 116 |
|
116 | 117 | static int vsock_client(unsigned int port, size_t size, |
117 | | - size_t count, int cid) |
| 118 | + size_t count, unsigned int cid) |
118 | 119 | { |
119 | 120 | struct sockaddr_vm addr; |
120 | 121 | size_t sendlen = 0; |
@@ -194,7 +195,7 @@ static int vsock_client(unsigned int port, size_t size, |
194 | 195 | return ret; |
195 | 196 | } |
196 | 197 |
|
197 | | -static int vsock_server(unsigned int port, size_t size, int cid) |
| 198 | +static int vsock_server(unsigned int port, size_t size, unsigned int cid) |
198 | 199 | { |
199 | 200 | struct sockaddr_vm peer_addr; |
200 | 201 | struct sockaddr_vm addr; |
@@ -426,9 +427,10 @@ static int vsock_server_conn(unsigned int port, int cid) |
426 | 427 |
|
427 | 428 | int main(int argc, char *argv[]) |
428 | 429 | { |
429 | | - int cid = VMADDR_CID_ANY; |
| 430 | + unsigned int cid = VMADDR_CID_ANY; |
430 | 431 | unsigned int port = 9999; |
431 | | - const char *type = NULL; |
| 432 | + FAR const char *type = NULL; |
| 433 | + FAR char *endptr; |
432 | 434 | size_t count = 100; |
433 | 435 | size_t size = 64; |
434 | 436 | int is_server = 1; |
@@ -459,7 +461,13 @@ int main(int argc, char *argv[]) |
459 | 461 | { |
460 | 462 | case 'c': |
461 | 463 | is_server = 0; |
462 | | - cid = strtoul(optarg, NULL, 0); |
| 464 | + cid = strtoul(optarg, &endptr, 0); |
| 465 | + if (errno != 0 || *endptr != '\0') |
| 466 | + { |
| 467 | + cid = 0; |
| 468 | + strncpy((FAR char *)&cid, optarg, |
| 469 | + MIN(sizeof(cid), strlen(optarg))); |
| 470 | + } |
463 | 471 | break; |
464 | 472 |
|
465 | 473 | case 't': |
|
0 commit comments