| 754 | } |
| 755 | |
| 756 | static int |
| 757 | parser_read_uint64(uint64_t *value, const char *p) |
| 758 | { |
| 759 | char *next; |
| 760 | uint64_t val; |
| 761 | |
| 762 | p = skip_white_spaces(p); |
| 763 | if (!isdigit(*p)) |
| 764 | return -EINVAL; |
| 765 | |
| 766 | val = strtoul(p, &next, 10); |
| 767 | if (p == next) |
| 768 | return -EINVAL; |
| 769 | |
| 770 | p = next; |
| 771 | switch (*p) { |
| 772 | case 'T': |
| 773 | val *= 1024ULL; |
| 774 | /* fall through */ |
| 775 | case 'G': |
| 776 | val *= 1024ULL; |
| 777 | /* fall through */ |
| 778 | case 'M': |
| 779 | val *= 1024ULL; |
| 780 | /* fall through */ |
| 781 | case 'k': |
| 782 | case 'K': |
| 783 | val *= 1024ULL; |
| 784 | p++; |
| 785 | break; |
| 786 | } |
| 787 | |
| 788 | p = skip_white_spaces(p); |
| 789 | if (*p != '\0') |
| 790 | return -EINVAL; |
| 791 | |
| 792 | *value = val; |
| 793 | return 0; |
| 794 | } |
| 795 | |
| 796 | int |
| 797 | parser_read_uint32(uint32_t *value, char *p) |
no test coverage detected