| 149 | } |
| 150 | |
| 151 | static bool from_number(u64 *res, const char *s, size_t len, int tens_factor) |
| 152 | { |
| 153 | if (len == 0) |
| 154 | return false; |
| 155 | |
| 156 | *res = 0; |
| 157 | for (size_t i = 0; i < len; i++) { |
| 158 | if (mul_overflows_u64(*res, 10)) |
| 159 | return false; |
| 160 | *res *= 10; |
| 161 | assert(cisdigit(s[i])); |
| 162 | if (add_overflows_u64(*res, s[i] - '0')) |
| 163 | return false; |
| 164 | *res += s[i] - '0'; |
| 165 | } |
| 166 | while (tens_factor > 0) { |
| 167 | if (mul_overflows_u64(*res, 10)) |
| 168 | return false; |
| 169 | *res *= 10; |
| 170 | tens_factor--; |
| 171 | } |
| 172 | return true; |
| 173 | } |
| 174 | |
| 175 | static bool from_numbers(u64 *res, |
| 176 | const char *s1, size_t len1, int tens_factor, |
no test coverage detected