Skip to content

Commit 82a453e

Browse files
committed
version: 1.3.1 fix null values in init macro and aliasing warning
1 parent 0082fc2 commit 82a453e

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

Flags.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
INC := $(INC)
22
INC := $(addprefix -I,$(INC))
3-
CFLAGS += -g -O0 -Wall -Wextra -Wmissing-declarations -Wconversion -Wshadow -Wlogical-op -Waggregate-return -Wfloat-equal -Wsuggest-attribute=const -Wunused -Wuninitialized -Wno-unknown-warning-option $(INC)
3+
CFLAGS += -g -O0 -Wall -Wextra -Wmissing-declarations -Wconversion -Wshadow -Wlogical-op -Waggregate-return -Wfloat-equal -Wsuggest-attribute=const -Wunused -Wuninitialized -Wno-unknown-warning-option -Wstrict-aliasing $(INC)
44

kJSON.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//------------------------------------------------------------------------------
66
// Purpose : Implements the kJSON API
77
//------------------------------------------------------------------------------
8-
// Version : 1.2.3
8+
// Version : 1.3.1
99
//------------------------------------------------------------------------------
1010
// Notes : None
1111
//------------------------------------------------------------------------------
@@ -65,6 +65,7 @@
6565

6666
#if !CONFIG_KJSON_NO_FLOAT
6767
#define FLOAT_MASK (0xFFFFFFFF)
68+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
6869
#define IS_FLOAT_NULL(value, nullValue) \
6970
((*(size_t *)&(value)&FLOAT_MASK) == (*(size_t *)&(nullValue)&FLOAT_MASK))
7071
#endif

kJSON.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//------------------------------------------------------------------------------
66
// Purpose : Defines the kJSON API
77
//------------------------------------------------------------------------------
8-
// Version : 1.3.0
8+
// Version : 1.3.1
99
//------------------------------------------------------------------------------
1010
// Notes : None
1111
//------------------------------------------------------------------------------
@@ -28,7 +28,7 @@ extern "C" {
2828

2929
#define KJSON_VERSION_MAJOR (1)
3030
#define KJSON_VERSION_MINOR (3)
31-
#define KJSON_VERSION_PATCH (0)
31+
#define KJSON_VERSION_PATCH (1)
3232

3333
#ifndef CONFIG_KJSON_SMALLEST
3434
#define CONFIG_KJSON_SMALLEST (1)
@@ -38,6 +38,7 @@ extern "C" {
3838
#define CONFIG_KJSON_NO_FLOAT (0)
3939
#endif
4040

41+
#if CONFIG_KJSON_NO_FLOAT
4142
#define KJSON_INITIALISE(buffer, bufferSize) \
4243
{ \
4344
.root = (buffer), \
@@ -47,8 +48,25 @@ extern "C" {
4748
.depth = 0, \
4849
.newLine = "\n", \
4950
.nullIntValue = (INT_MAX), \
51+
.nullUIntValue = (UINT_MAX), \
5052
.truncated = false \
5153
}
54+
#else
55+
#include <float.h>
56+
#define KJSON_INITIALISE(buffer, bufferSize) \
57+
{ \
58+
.root = (buffer), \
59+
.rootSize = (bufferSize), \
60+
.tail = (buffer), \
61+
.size = 0, \
62+
.depth = 0, \
63+
.newLine = "\n", \
64+
.nullIntValue = (INT_MAX), \
65+
.nullUIntValue = (UINT_MAX), \
66+
.nullFloatValue = (FLT_MAX), \
67+
.truncated = false \
68+
}
69+
#endif
5270

5371
//------------------------------------------------------------------------------
5472
// Module exported type definitions

0 commit comments

Comments
 (0)