diff --git a/.gitattributes b/.gitattributes index c892176c36fb46dc278fc25b0f0cc41743891f1b_LmdpdGF0dHJpYnV0ZXM=..a1c065d0c6afb55e3ff73860c47556bb1df4ca3a_LmdpdGF0dHJpYnV0ZXM= 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,8 @@ * text=auto -/tests/inputs/* text eol=lf \ No newline at end of file +/tests/inputs/* text eol=lf + +.gitattributes export-ignore +.gitignore export-ignore +.github export-ignore +.editorconfig export-ignore +.travis.yml export-ignore diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000000000000000000000000000000000000..a1c065d0c6afb55e3ff73860c47556bb1df4ca3a_LmdpdGh1Yi93b3JrZmxvd3MvQ0kueW1s --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,102 @@ +name: CI + +on: + push: + branches: [ master ] + paths-ignore: + - '**.md' + - 'LICENSE' + pull_request: + types: [opened, synchronize] + paths-ignore: + - '**.md' + - 'LICENSE' + +jobs: + linux: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + fail-fast: false + matrix: + mem_check: + - ENABLE_VALGRIND + - ENABLE_SANITIZERS + - NONE_MEM_CHECK + compiler: + - GCC + - CLANG + steps: + - uses: actions/checkout@v2 + - name: install build dependencies + run: | + sudo apt-get update + sudo apt-get install clang-8 valgrind + - name: build and test + shell: bash + run: | + if [ "${{ matrix.mem_check }}" == "ENABLE_VALGRIND" ]; then + EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=ON -DENABLE_SAFE_STACK=ON -DENABLE_SANITIZERS=OFF" + elif [ "${{ matrix.mem_check }}" == "ENABLE_SANITIZERS" ]; then + EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=OFF -DENABLE_SAFE_STACK=OFF -DENABLE_SANITIZERS=ON" + else + EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=OFF -DENABLE_SAFE_STACK=OFF -DENABLE_SANITIZERS=OFF" + fi + if [ "${{ matrix.compiler }}" == "GCC" ]; then + export CC=gcc + else + export CC=clang + fi + #run build and test + JOBS=20 + export CTEST_PARALLEL_LEVEL=$JOBS + export CTEST_OUTPUT_ON_FAILURE=1 + mkdir -p build + cd build + echo [cmake]: cmake .. $EVENT_CMAKE_OPTIONS + cmake .. $EVENT_CMAKE_OPTIONS || (rm -rf * && cmake .. $EVENT_CMAKE_OPTIONS) + cmake --build . + make + make test + + macos: + runs-on: macos-latest + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + fail-fast: false + matrix: + mem_check: + - ENABLE_VALGRIND + - ENABLE_SANITIZERS + - NONE_MEM_CHECK + compiler: + - GCC + - CLANG + steps: + - uses: actions/checkout@v2 + - name: build and test + shell: bash + run: | + if [ "${{ matrix.mem_check }}" == "ENABLE_VALGRIND" ]; then + EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=ON -DENABLE_SAFE_STACK=ON -DENABLE_SANITIZERS=OFF" + elif [ "${{ matrix.mem_check }}" == "ENABLE_SANITIZERS" ]; then + EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=OFF -DENABLE_SAFE_STACK=OFF -DENABLE_SANITIZERS=ON" + else + EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=OFF -DENABLE_SAFE_STACK=OFF -DENABLE_SANITIZERS=OFF" + fi + if [ "${{ matrix.compiler }}" == "GCC" ]; then + export CC=gcc + else + export CC=clang + fi + #run build and test + JOBS=20 + export CTEST_PARALLEL_LEVEL=$JOBS + export CTEST_OUTPUT_ON_FAILURE=1 + mkdir -p build + cd build + echo [cmake]: cmake .. $EVENT_CMAKE_OPTIONS + cmake .. $EVENT_CMAKE_OPTIONS || (rm -rf * && cmake .. $EVENT_CMAKE_OPTIONS) + cmake --build . + make + make test diff --git a/CMakeLists.txt b/CMakeLists.txt index c892176c36fb46dc278fc25b0f0cc41743891f1b_Q01ha2VMaXN0cy50eHQ=..a1c065d0c6afb55e3ff73860c47556bb1df4ca3a_Q01ha2VMaXN0cy50eHQ= 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,6 @@ -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined - -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize-address-use-after-scope -fsanitize=integer diff --git a/cJSON.c b/cJSON.c index c892176c36fb46dc278fc25b0f0cc41743891f1b_Y0pTT04uYw==..a1c065d0c6afb55e3ff73860c47556bb1df4ca3a_Y0pTT04uYw== 100644 --- a/cJSON.c +++ b/cJSON.c @@ -96,7 +96,7 @@ return (const char*) (global_error.json + global_error.position); } -CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) +CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item) { if (!cJSON_IsString(item)) { @@ -106,7 +106,7 @@ return item->valuestring; } -CJSON_PUBLIC(double) cJSON_GetNumberValue(cJSON *item) +CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item) { if (!cJSON_IsNumber(item)) { @@ -110,7 +110,7 @@ { if (!cJSON_IsNumber(item)) { - return NAN; + return (double) NAN; } return item->valuedouble; diff --git a/cJSON.h b/cJSON.h index c892176c36fb46dc278fc25b0f0cc41743891f1b_Y0pTT04uaA==..a1c065d0c6afb55e3ff73860c47556bb1df4ca3a_Y0pTT04uaA== 100644 --- a/cJSON.h +++ b/cJSON.h @@ -176,8 +176,8 @@ CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); /* Check item type and return its value */ -CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item); -CJSON_PUBLIC(double) cJSON_GetNumberValue(cJSON *item); +CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item); +CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item); /* These functions check the type of an item */ CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);