From 466eb8e3f8a65080f2b3ca4a79ab7b72bd539dba Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Sat, 18 Mar 2017 17:52:04 +0100 Subject: [PATCH] Fix wconversion with old gcc (e.g. 4.3) --- cJSON.c | 8 ++++---- cJSON_Utils.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cJSON.c b/cJSON.c index 6b60b9a..e8ed3b3 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1226,7 +1226,7 @@ static cJSON_bool print_array(const cJSON * const item, const size_t depth, cons update_offset(output_buffer); if (current_element->next) { - length = format ? 2 : 1; + length = (size_t) (format ? 2 : 1); output_pointer = ensure(output_buffer, length + 1, hooks); if (output_pointer == NULL) { @@ -1362,7 +1362,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con } /* Compose the output: */ - length = format ? 2 : 1; /* fmt: {\n */ + length = (size_t) (format ? 2 : 1); /* fmt: {\n */ output_pointer = ensure(output_buffer, length + 1, hooks); if (output_pointer == NULL) { @@ -1400,7 +1400,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con } update_offset(output_buffer); - length = format ? 2 : 1; + length = (size_t) (format ? 2 : 1); output_pointer = ensure(output_buffer, length, hooks); if (output_pointer == NULL) { @@ -1421,7 +1421,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con update_offset(output_buffer); /* print comma if not last */ - length = (size_t) (format ? 1 : 0) + (current_item->next ? 1 : 0); + length = (size_t) ((format ? 1 : 0) + (current_item->next ? 1 : 0)); output_pointer = ensure(output_buffer, length + 1, hooks); if (output_pointer == NULL) { diff --git a/cJSON_Utils.c b/cJSON_Utils.c index b18def3..8fe4ff0 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -230,11 +230,11 @@ static void cJSONUtils_InplaceDecodePointerString(unsigned char *string) for (; *string; (void)s2++, string++) { - *s2 = (*string != '~') + *s2 = (unsigned char) ((*string != '~') ? (*string) : ((*(++string) == '0') ? '~' - : '/'); + : '/')); } *s2 = '\0';