mirror of
https://github.com/DaveGamble/cJSON.git
synced 2025-01-14 11:40:17 +08:00
Compiler flag -Wswitch-default + add defaults
This commit is contained in:
parent
fe18403935
commit
b182ced1d6
@ -15,7 +15,7 @@ set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT
|
|||||||
option(ENABLE_CUSTOM_COMPILER_FLAGS "Enables custom compiler flags for Clang and GCC" ON)
|
option(ENABLE_CUSTOM_COMPILER_FLAGS "Enables custom compiler flags for Clang and GCC" ON)
|
||||||
if (ENABLE_CUSTOM_COMPILER_FLAGS)
|
if (ENABLE_CUSTOM_COMPILER_FLAGS)
|
||||||
if(("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang"))
|
if(("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang"))
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89 -pedantic -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes -Wstrict-overflow=2 -Wcast-qual -Wc++-compat -Wundef")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89 -pedantic -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes -Wstrict-overflow=2 -Wcast-qual -Wc++-compat -Wundef -Wswitch-default")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
2
Makefile
2
Makefile
@ -23,7 +23,7 @@ INSTALL_LIBRARY_PATH = $(DESTDIR)$(PREFIX)/$(LIBRARY_PATH)
|
|||||||
|
|
||||||
INSTALL ?= cp -a
|
INSTALL ?= cp -a
|
||||||
|
|
||||||
R_CFLAGS = -fPIC -std=c89 -pedantic -Wall -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes -Wstrict-overflow=2 -Wcast-qual -Wc++-compat -Wundef $(CFLAGS)
|
R_CFLAGS = -fPIC -std=c89 -pedantic -Wall -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes -Wstrict-overflow=2 -Wcast-qual -Wc++-compat -Wundef -Wswitch-default $(CFLAGS)
|
||||||
|
|
||||||
uname := $(shell sh -c 'uname -s 2>/dev/null || echo false')
|
uname := $(shell sh -c 'uname -s 2>/dev/null || echo false')
|
||||||
|
|
||||||
|
9
cJSON.c
9
cJSON.c
@ -645,6 +645,9 @@ static const char *parse_string(cJSON *item, const char *str, const char **ep)
|
|||||||
/* depending on the length in bytes this determines the
|
/* depending on the length in bytes this determines the
|
||||||
* encoding ofthe first UTF8 byte */
|
* encoding ofthe first UTF8 byte */
|
||||||
*--ptr2 = (uc | firstByteMark[len]);
|
*--ptr2 = (uc | firstByteMark[len]);
|
||||||
|
default:
|
||||||
|
*ep = str;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
ptr2 += len;
|
ptr2 += len;
|
||||||
break;
|
break;
|
||||||
@ -1032,6 +1035,9 @@ static char *print_value(const cJSON *item, int depth, cjbool fmt, printbuffer *
|
|||||||
case cJSON_Object:
|
case cJSON_Object:
|
||||||
out = print_object(item, depth, fmt, p);
|
out = print_object(item, depth, fmt, p);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
out = NULL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1062,6 +1068,9 @@ static char *print_value(const cJSON *item, int depth, cjbool fmt, printbuffer *
|
|||||||
case cJSON_Object:
|
case cJSON_Object:
|
||||||
out = print_object(item, depth, fmt, 0);
|
out = print_object(item, depth, fmt, 0);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
out = NULL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user