mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Consider the sparse warnings and __DBL_EPSILON__
Some values expected to be initialized with NULL was being initialized with 0 triggering sparse warnings Also DBL_EPSILON on Linux GCC dependes on __DBL_EPSILON__ causing trouble on compilation.
This commit is contained in:
parent
b45f48e600
commit
dbf111a4c8
14
cJSON.c
14
cJSON.c
@ -58,6 +58,10 @@
|
|||||||
|
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
|
|
||||||
|
#ifndef __DBL_EPSILON__
|
||||||
|
#define __DBL_EPSILON__ 2.2204460492503131e-16
|
||||||
|
#endif
|
||||||
|
|
||||||
/* define our own boolean type */
|
/* define our own boolean type */
|
||||||
#ifdef true
|
#ifdef true
|
||||||
#undef true
|
#undef true
|
||||||
@ -1094,7 +1098,7 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return
|
|||||||
/* Parse an object - create a new root, and populate. */
|
/* Parse an object - create a new root, and populate. */
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated)
|
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated)
|
||||||
{
|
{
|
||||||
parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
|
parse_buffer buffer = { NULL, 0, 0, 0, { NULL, NULL, NULL } };
|
||||||
cJSON *item = NULL;
|
cJSON *item = NULL;
|
||||||
|
|
||||||
/* reset error position */
|
/* reset error position */
|
||||||
@ -1174,12 +1178,12 @@ fail:
|
|||||||
/* Default options for cJSON_Parse */
|
/* Default options for cJSON_Parse */
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)
|
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)
|
||||||
{
|
{
|
||||||
return cJSON_ParseWithOpts(value, 0, 0);
|
return cJSON_ParseWithOpts(value, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length)
|
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length)
|
||||||
{
|
{
|
||||||
return cJSON_ParseWithLengthOpts(value, buffer_length, 0, 0);
|
return cJSON_ParseWithLengthOpts(value, buffer_length, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define cjson_min(a, b) (((a) < (b)) ? (a) : (b))
|
#define cjson_min(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
@ -1261,7 +1265,7 @@ CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item)
|
|||||||
|
|
||||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)
|
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)
|
||||||
{
|
{
|
||||||
printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
|
printbuffer p = { NULL, 0, 0, 0, 0, 0, { NULL, NULL, NULL } };
|
||||||
|
|
||||||
if (prebuffer < 0)
|
if (prebuffer < 0)
|
||||||
{
|
{
|
||||||
@ -1291,7 +1295,7 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
|
|||||||
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)
|
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)
|
||||||
{
|
{
|
||||||
printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
|
printbuffer p = { NULL, 0, 0, 0, 0, 0, { NULL, NULL, NULL } };
|
||||||
|
|
||||||
if ((length < 0) || (buffer == NULL))
|
if ((length < 0) || (buffer == NULL))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user