| 67 | |
| 68 | |
| 69 | bool json_to_u64(const char *buffer, const jsmntok_t *tok, u64 *num) |
| 70 | { |
| 71 | char *end; |
| 72 | unsigned long long l; |
| 73 | |
| 74 | l = strtoull(buffer + tok->start, &end, 0); |
| 75 | if (end != buffer + tok->end) |
| 76 | return false; |
| 77 | |
| 78 | BUILD_ASSERT(sizeof(l) >= sizeof(*num)); |
| 79 | *num = l; |
| 80 | |
| 81 | /* Check for overflow */ |
| 82 | if (l == ULLONG_MAX && errno == ERANGE) |
| 83 | return false; |
| 84 | |
| 85 | if (*num != l) |
| 86 | return false; |
| 87 | |
| 88 | return true; |
| 89 | } |
| 90 | |
| 91 | bool json_to_u32(const char *buffer, const jsmntok_t *tok, u32 *num) |
| 92 | { |
no outgoing calls