mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Merge pull request #139 from PawelWMS/develop_W4_fixes
Fixing all /W4 level warnings.
This commit is contained in:
commit
f0230a584f
15
cJSON.c
15
cJSON.c
@ -23,7 +23,10 @@
|
|||||||
/* cJSON */
|
/* cJSON */
|
||||||
/* JSON parser in C. */
|
/* JSON parser in C. */
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
#pragma GCC visibility push(default)
|
#pragma GCC visibility push(default)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -32,7 +35,10 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
#pragma GCC visibility pop
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
|
|
||||||
@ -956,7 +962,7 @@ static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer)
|
|||||||
/* Parse an object - create a new root, and populate. */
|
/* Parse an object - create a new root, and populate. */
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated)
|
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated)
|
||||||
{
|
{
|
||||||
parse_buffer buffer;
|
parse_buffer buffer = { 0 };
|
||||||
cJSON *item = NULL;
|
cJSON *item = NULL;
|
||||||
|
|
||||||
/* reset error position */
|
/* reset error position */
|
||||||
@ -1040,7 +1046,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)
|
|||||||
return cJSON_ParseWithOpts(value, 0, 0);
|
return cJSON_ParseWithOpts(value, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define min(a, b) ((a < b) ? a : b)
|
#define cjson_min(a, b) ((a < b) ? a : b)
|
||||||
|
|
||||||
static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
|
static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1085,7 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
|
|||||||
{
|
{
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
memcpy(printed, buffer->buffer, min(buffer->length, buffer->offset + 1));
|
memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1));
|
||||||
printed[buffer->offset] = '\0'; /* just to be sure */
|
printed[buffer->offset] = '\0'; /* just to be sure */
|
||||||
|
|
||||||
/* free the buffer */
|
/* free the buffer */
|
||||||
@ -1771,7 +1777,10 @@ CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSO
|
|||||||
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
|
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Add an item to an object with constant string as key */
|
/* Add an item to an object with constant string as key */
|
||||||
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
|
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
|
||||||
{
|
{
|
||||||
|
2
cJSON.h
2
cJSON.h
@ -150,7 +150,7 @@ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
|||||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int item);
|
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int item);
|
||||||
/* Get item "string" from object. Case insensitive. */
|
/* Get item "string" from object. Case insensitive. */
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON *object, const char *string);
|
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON *object, const char *string);
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON *object, const char *string);
|
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user