| 136 | } |
| 137 | |
| 138 | static bool from_number(u64 *res, const char *s, size_t len, int tens_factor) |
| 139 | { |
| 140 | if (len == 0) |
| 141 | return false; |
| 142 | |
| 143 | *res = 0; |
| 144 | for (size_t i = 0; i < len; i++) { |
| 145 | if (mul_overflows_u64(*res, 10)) |
| 146 | return false; |
| 147 | *res *= 10; |
| 148 | assert(cisdigit(s[i])); |
| 149 | if (add_overflows_u64(*res, s[i] - '0')) |
| 150 | return false; |
| 151 | *res += s[i] - '0'; |
| 152 | } |
| 153 | while (tens_factor > 0) { |
| 154 | if (mul_overflows_u64(*res, 10)) |
| 155 | return false; |
| 156 | *res *= 10; |
| 157 | tens_factor--; |
| 158 | } |
| 159 | return true; |
| 160 | } |
| 161 | |
| 162 | static bool from_numbers(u64 *res, |
| 163 | const char *s1, size_t len1, int tens_factor, |
no test coverage detected