| 54 | }) |
| 55 | |
| 56 | static int |
| 57 | parser_read_uint64(uint64_t *value, const char *p) |
| 58 | { |
| 59 | char *next; |
| 60 | uint64_t val; |
| 61 | |
| 62 | p = skip_white_spaces(p); |
| 63 | if (!isdigit(*p)) |
| 64 | return -EINVAL; |
| 65 | |
| 66 | val = strtoul(p, &next, 0); |
| 67 | if (p == next) |
| 68 | return -EINVAL; |
| 69 | |
| 70 | p = next; |
| 71 | switch (*p) { |
| 72 | case 'T': |
| 73 | val *= 1024ULL; |
| 74 | /* fall through */ |
| 75 | case 'G': |
| 76 | val *= 1024ULL; |
| 77 | /* fall through */ |
| 78 | case 'M': |
| 79 | val *= 1024ULL; |
| 80 | /* fall through */ |
| 81 | case 'k': |
| 82 | case 'K': |
| 83 | val *= 1024ULL; |
| 84 | p++; |
| 85 | break; |
| 86 | } |
| 87 | |
| 88 | p = skip_white_spaces(p); |
| 89 | if (*p != '\0') |
| 90 | return -EINVAL; |
| 91 | |
| 92 | *value = val; |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | static int |
| 97 | parser_read_uint32(uint32_t *value, const char *p) |
no test coverage detected