strtoul -> strtoull (don't assume LP64 for Windows)

This commit is contained in:
fincs 2018-05-03 01:15:43 +02:00
parent e68cd31c1d
commit e2d64bb2fe
2 changed files with 4 additions and 4 deletions

View File

@ -131,7 +131,7 @@ int cJSON_GetU64(const cJSON *obj, const char *field, u64 *out) {
const cJSON *config = cJSON_GetObjectItemCaseSensitive(obj, field); const cJSON *config = cJSON_GetObjectItemCaseSensitive(obj, field);
if (cJSON_IsString(config) && (config->valuestring != NULL)) { if (cJSON_IsString(config) && (config->valuestring != NULL)) {
char *endptr = NULL; char *endptr = NULL;
*out = strtoul(config->valuestring, &endptr, 16); *out = strtoull(config->valuestring, &endptr, 16);
if (config->valuestring == endptr) { if (config->valuestring == endptr) {
fprintf(stderr, "Failed to get %s (empty string)\n", field); fprintf(stderr, "Failed to get %s (empty string)\n", field);
return 0; return 0;
@ -156,7 +156,7 @@ int cJSON_GetU64(const cJSON *obj, const char *field, u64 *out) {
int cJSON_GetU64FromObjectValue(const cJSON *config, u64 *out) { int cJSON_GetU64FromObjectValue(const cJSON *config, u64 *out) {
if (cJSON_IsString(config) && (config->valuestring != NULL)) { if (cJSON_IsString(config) && (config->valuestring != NULL)) {
char *endptr = NULL; char *endptr = NULL;
*out = strtoul(config->valuestring, &endptr, 16); *out = strtoull(config->valuestring, &endptr, 16);
if (config->valuestring == endptr) { if (config->valuestring == endptr) {
fprintf(stderr, "Failed to get %s (empty string)\n", config->string); fprintf(stderr, "Failed to get %s (empty string)\n", config->string);
return 0; return 0;

View File

@ -184,7 +184,7 @@ int cJSON_GetU64(const cJSON *obj, const char *field, u64 *out) {
const cJSON *config = cJSON_GetObjectItemCaseSensitive(obj, field); const cJSON *config = cJSON_GetObjectItemCaseSensitive(obj, field);
if (cJSON_IsString(config) && (config->valuestring != NULL)) { if (cJSON_IsString(config) && (config->valuestring != NULL)) {
char *endptr = NULL; char *endptr = NULL;
*out = strtoul(config->valuestring, &endptr, 16); *out = strtoull(config->valuestring, &endptr, 16);
if (config->valuestring == endptr) { if (config->valuestring == endptr) {
fprintf(stderr, "Failed to get %s (empty string)\n", field); fprintf(stderr, "Failed to get %s (empty string)\n", field);
return 0; return 0;
@ -209,7 +209,7 @@ int cJSON_GetU64(const cJSON *obj, const char *field, u64 *out) {
int cJSON_GetU64FromObjectValue(const cJSON *config, u64 *out) { int cJSON_GetU64FromObjectValue(const cJSON *config, u64 *out) {
if (cJSON_IsString(config) && (config->valuestring != NULL)) { if (cJSON_IsString(config) && (config->valuestring != NULL)) {
char *endptr = NULL; char *endptr = NULL;
*out = strtoul(config->valuestring, &endptr, 16); *out = strtoull(config->valuestring, &endptr, 16);
if (config->valuestring == endptr) { if (config->valuestring == endptr) {
fprintf(stderr, "Failed to get %s (empty string)\n", config->string); fprintf(stderr, "Failed to get %s (empty string)\n", config->string);
return 0; return 0;