* Parse num options at run time. */
| 612 | * Parse num options at run time. |
| 613 | */ |
| 614 | static int |
| 615 | parse_num_opt(const char *q_arg, uint32_t max_valid_value) |
| 616 | { |
| 617 | char *end = NULL; |
| 618 | unsigned long num; |
| 619 | |
| 620 | errno = 0; |
| 621 | |
| 622 | /* parse unsigned int string */ |
| 623 | num = strtoul(q_arg, &end, 10); |
| 624 | if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0') || (errno != 0)) |
| 625 | return -1; |
| 626 | |
| 627 | if (num > max_valid_value) |
| 628 | return -1; |
| 629 | |
| 630 | return num; |
| 631 | |
| 632 | } |
| 633 | |
| 634 | /* |
| 635 | * Display usage |
no test coverage detected