| 464 | } |
| 465 | return (int)v; |
| 466 | } |
| 467 | |
| 468 | static int parse_nonnegative_int(const char *s, const char *opt) { |
| 469 | char *end = NULL; |
| 470 | long v = strtol(s, &end, 10); |
| 471 | if (s[0] == '\0' || *end != '\0' || v < 0 || v > INT32_MAX) { |
| 472 | fprintf(stderr, "ds4-agent: invalid value for %s: %s\n", opt, s); |
| 473 | exit(2); |
| 474 | } |
| 475 | return (int)v; |
| 476 | } |
| 477 |