| 190 | static int parse_nonnegative_int(const char *s, const char *opt) { |
| 191 | char *end = NULL; |
| 192 | long v = strtol(s, &end, 10); |
| 193 | if (s[0] == '\0' || *end != '\0' || v < 0 || v > INT32_MAX) { |
| 194 | fprintf(stderr, "ds4: invalid value for %s: %s\n", opt, s); |
| 195 | exit(2); |
| 196 | } |
| 197 | return (int)v; |
| 198 | } |
| 199 | |
| 200 | static uint64_t parse_u64(const char *s, const char *opt) { |
| 201 | char *end = NULL; |
| 202 | unsigned long long v = strtoull(s, &end, 10); |
| 203 | if (s[0] == '\0' || *end != '\0' || v == 0) { |
| 204 | fprintf(stderr, "ds4: invalid value for %s: %s\n", opt, s); |
| 205 | exit(2); |
| 206 | } |
| 207 | return (uint64_t)v; |
| 208 | } |
| 209 | |
| 210 | static float parse_float_range(const char *s, const char *opt, float min, float max) { |
no test coverage detected