Giter Club home page Giter Club logo

checkedc-parson's Introduction

About

This Checked C version of parson is a fork of the parson JSON parsing library by kgabis (https://github.com/kgabis/parson)). The code is converted into Checked C to provide bounds guarantees from the compiler (see https://github.com/Microsoft/checkedc for more information). DO NOT USE THIS CODE IN PRODUCTION. It is not kept up to date with the main parson project.

Usage

Requires the checkedc-clang compiler (https://github.com/Microsoft/checkedc-clang) to build. If that is not aliased to clang on your system, edit the Makefile to set CC appropriately.

On UNIX

To build only: make compile

To build and then run the unit tests: make or make test

On Windows

To build only: nmake -f Makefile.win

To build and then run the unit tests nmake -f Makefile.win or nmake -f Makefile.win test

Branches

  • baseline: The original C code that the conversion starts from. Note that this is already behind the main parson project. This branch should pass all 325 unit tests.
  • master: The converted Checked C code. This branch should pass all 325 unit tests.
  • version1-summer-2018: This was our first take at converting parson to Checked C. The master branch has the 2nd take on conversion. It introduces fewer itypes and adds length arguments in a cleaner fashion.

License

The MIT License (MIT)

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

checkedc-parson's People

Contributors

9re avatar annakornfeldsimpson avatar dtarditi avatar erikdubbelboer avatar i-rinat avatar indutny avatar jacobenget avatar jetstreamroysprowl avatar jmlemetayer avatar kgabis avatar lunixoid avatar michaelsproul avatar microsoft-github-policy-service[bot] avatar sulekhark avatar tbeu avatar vovanec avatar w32zhong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

checkedc-parson's Issues

Compile errors occured at Linux

On my Debian GNU/Linux PC, this code causes following compile errors:

$ git clone [email protected]:microsoft/checkedc-clang.git
$ cd checkedc-parson/llvm/projects/checkedc-wrapper
$ git clone [email protected]:microsoft/checkedc.git
$ cd ../../../..
$ mkdir checkedc-clang-build
$ cd checkedc-clang-build
$ cmake -G Ninja -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS=clang ../checkedc-clang/llvm
$ ninja clang
$ ./bin/clang --version
clang version 9.0.0 ([email protected]:microsoft/checkedc-clang.git 07c6082412d73d07676014a78651af56d327acc8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/kiwamu/src/checkedc/checkedc-clang-build/./bin
$ git clone [email protected]:microsoft/checkedc-parson.git
$ ls
checkedc-clang/  checkedc-clang-build/  checkedc-parson/  parson/
$ cd checkedc-parson
$ git diff
diff --git a/Makefile b/Makefile
index 3972877..7cb6519 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CC = clang
+CC = ../checkedc-clang-build/bin/clang
 CFLAGS = -O0 -g -Wall -Wextra -std=c99 -pedantic-errors
 
 all: test
diff --git a/tests.c b/tests.c
index 76c1611..f067a92 100644
--- a/tests.c
+++ b/tests.c
@@ -68,10 +68,12 @@ static int tests_passed;
 static int tests_failed;
 
 int main() {
+    int i;
     /* Example functions from readme file:      */
     /* print_commits_info("torvalds", "linux"); */
     /* serialization_example(); */
     /* persistence_example(); */
+    for (i = 0; i < 1000; i++) {
     json_set_allocation_functions(counted_malloc, counted_free);
     test_suite_1();
     test_suite_2_no_comments();
@@ -88,6 +90,7 @@ int main() {
 
     printf("Tests failed: %d\n", tests_failed);
     printf("Tests passed: %d\n", tests_passed);
+    }
     return 0;
 }
$ make compile |& grep -A 6 error
../checkedc-clang-build/bin/clang -O0 -g -Wall -Wextra -std=c99 -pedantic-errors -o test tests.c parson.c
parson.c:78:29: error: static variable 'parson_malloc' has a type that uses a type variable bound in an enclosing scope (type is 'JSON_Malloc_Function' and type variable is 'T')
static JSON_Malloc_Function parson_malloc;
                            ^
./parson.h:63:24: note: type variable 'T' declared here
typedef _Itype_for_any(T) void * tmp_malloc_fun(size_t s) : byte_count(s) itype(_Array_ptr<T>);
                       ^
parson.c:79:27: error: static variable 'parson_free' has a type that uses a type variable bound in an enclosing scope (type is 'JSON_Free_Function' and type variable is 'T')
static JSON_Free_Function parson_free;
                          ^
./parson.h:64:24: note: type variable 'T' declared here
typedef _Itype_for_any(T) void tmp_free_fun(void * : byte_count(0) itype(_Array_ptr<T>));
                       ^
parson.c:292:35: warning: cannot prove argument meets declared bounds for 1st parameter [-Wcheck-bounds-decls-checked-scope]
--
44 warnings and 2 errors generated.
make: *** [Makefile:12: compile] Error 1

How to fix them?

Doesn't compile on MacOS 10.14

Just tried to build this with the latest Checked C on MacOS 10.14.5 (and Xcode 10.2.1) and it doesn't succeed. Very long transcript follows.

I am using Checked C clang commit a35072baee9fcb267e0e2dc2842fa55a600eca0f

[ checkedc-parson ]> make CC=~/research/projects/checkedc/llvm.obj/bin/clang compile
/Users/mwhicks/research/projects/checkedc/llvm.obj/bin/clang -O0 -g -Wall -Wextra -std=c99 -pedantic-errors -o test tests.c parson.c
tests.c:638:25: warning: cannot prove declared bounds for 'file_contents' are
      valid after initialization [-Wcheck-bounds-decls-checked-scope]
  ...file_contents : count(file_size * (size_t)1) = (_Nt_array_ptr<char>) malloc<char>((file_size + 1) * sizeof(char));
     ^~~~~~~~~~~~~                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.c:638:25: note: (expanded) declared bounds are 'bounds(file_contents,
      file_contents + file_size * (size_t)1)'
    _Nt_array_ptr<char> file_contents : count(file_size * (size_t)1) = (...
                        ^~~~~~~~~~~~~
tests.c:638:72: note: (expanded) inferred bounds are
      'bounds((_Array_ptr<char>)value of malloc((file_size + 1) * sizeof(char)),
      (_Array_ptr<char>)value of malloc((file_size + 1) * sizeof(char)) +
      (file_size + 1) * sizeof(char))'
  ...= (_Nt_array_ptr<char>) malloc<char>((file_size + 1) * sizeof(char));
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from parson.c:40:
/Users/mwhicks/research/projects/checkedc/llvm.obj/lib/clang/8.0.0/include/errno_checked.h:27:55: error: 
      expected function body after function declarator
extern int* __errno_location(void) : itype(_Ptr<int>) __THROW __attribut...
                                                      ^
parson.c:168:28: warning: cannot prove argument meets declared bounds for 2nd
      parameter [-Wcheck-bounds-decls-checked-scope]
    strncpy(output_string, string, n);
                           ^~~~~~
/usr/include/secure/_string.h:124:34: note: expanded from macro 'strncpy'
                __builtin___strncpy_chk (dest, __VA_ARGS__, __darwin_obs...
                                               ^~~~~~~~~~~
parson.c:168:28: note: (expanded) expected argument bounds are 'bounds((const
      char *)string, (const char *)string + n)'
parson.c:168:28: note: (expanded) inferred bounds are 'bounds(string, string +
      0)'
    strncpy(output_string, string, n);
                           ^~~~~~
/usr/include/secure/_string.h:124:34: note: expanded from macro 'strncpy'
                __builtin___strncpy_chk (dest, __VA_ARGS__, __darwin_obs...
                                               ^~~~~~~~~~~
parson.c:510:9: error: return used in a checked scope must have a checked type
      or a bounds-safe interface
        memcpy<_Ptr<JSON_Value>>(_Dynamic_bounds_cast<_Array_ptr<_Ptr<JS...
        ^
/usr/include/string.h:72:1: note: return declared here
void    *memcpy(void *__dst, const void *__src, size_t __n);
^
parson.c:668:5: error: return used in a checked scope must have a checked type
      or a bounds-safe interface
    memcpy<char>(resized_output, tmp_rebounded_output, final_size);
    ^
/usr/include/string.h:72:1: note: return declared here
void    *memcpy(void *__dst, const void *__src, size_t __n);
^
parson.c:941:54: warning: cannot prove argument meets declared bounds for 2nd
      parameter [-Wcheck-bounds-decls-checked-scope]
                written = json_serialize_string(key, buf, buf_start, buf_len);
                                                     ^~~
parson.c:941:54: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (unsigned int)buf_len)'
parson.c:941:54: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
                written = json_serialize_string(key, buf, buf_start, buf_len);
                                                     ^~~
parson.c:979:53: warning: cannot prove argument meets declared bounds for 2nd
      parameter [-Wcheck-bounds-decls-checked-scope]
            written = json_serialize_string(string, buf, buf_start, buf_len);
                                                    ^~~
parson.c:979:53: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (unsigned int)buf_len)'
parson.c:979:53: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            written = json_serialize_string(string, buf, buf_start, buf_len);
                                                    ^~~
parson.c:998:25: warning: cannot prove declared bounds for num_buf are valid
      after assignment [-Wcheck-bounds-decls-checked-scope]
                num_buf = buf;
                ~~~~~~~ ^ ~~~
parson.c:998:17: note: (expanded) declared bounds are 'bounds(num_buf, num_buf +
      0)'
                num_buf = buf;
                ^
parson.c:998:27: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
                num_buf = buf;
                          ^~~
parson.c:1032:5: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
    APPEND_STRING("\"");
    ^~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1032:5: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1032:5: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
    APPEND_STRING("\"");
    ^~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1085:5: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
    APPEND_STRING("\"");
    ^~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1085:5: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1085:5: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
    APPEND_STRING("\"");
    ^~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1036:24: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\"': APPEND_STRING("\\\""); break;
                       ^~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1036:24: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1036:24: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\"': APPEND_STRING("\\\""); break;
                       ^~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1037:24: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\\': APPEND_STRING("\\\\"); break;
                       ^~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1037:24: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1037:24: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\\': APPEND_STRING("\\\\"); break;
                       ^~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1038:24: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '/':  APPEND_STRING("\\/"); break; /* to make json embe...
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1038:24: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1038:24: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '/':  APPEND_STRING("\\/"); break; /* to make json embe...
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1039:24: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\b': APPEND_STRING("\\b"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1039:24: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1039:24: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\b': APPEND_STRING("\\b"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1040:24: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\f': APPEND_STRING("\\f"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1040:24: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1040:24: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\f': APPEND_STRING("\\f"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1041:24: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\n': APPEND_STRING("\\n"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1041:24: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1041:24: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\n': APPEND_STRING("\\n"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1042:24: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\r': APPEND_STRING("\\r"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1042:24: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1042:24: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\r': APPEND_STRING("\\r"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1043:24: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\t': APPEND_STRING("\\t"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1043:24: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1043:24: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\t': APPEND_STRING("\\t"); break;
                       ^~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1044:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x00': APPEND_STRING("\\u0000"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1044:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1044:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x00': APPEND_STRING("\\u0000"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1045:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x01': APPEND_STRING("\\u0001"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1045:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1045:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x01': APPEND_STRING("\\u0001"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1046:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x02': APPEND_STRING("\\u0002"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1046:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1046:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x02': APPEND_STRING("\\u0002"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1047:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x03': APPEND_STRING("\\u0003"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1047:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1047:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x03': APPEND_STRING("\\u0003"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1048:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x04': APPEND_STRING("\\u0004"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1048:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1048:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x04': APPEND_STRING("\\u0004"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1049:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x05': APPEND_STRING("\\u0005"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1049:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1049:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x05': APPEND_STRING("\\u0005"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1050:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x06': APPEND_STRING("\\u0006"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1050:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1050:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x06': APPEND_STRING("\\u0006"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1051:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x07': APPEND_STRING("\\u0007"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1051:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1051:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x07': APPEND_STRING("\\u0007"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1055:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x0b': APPEND_STRING("\\u000b"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1055:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1055:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x0b': APPEND_STRING("\\u000b"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1058:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x0e': APPEND_STRING("\\u000e"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1058:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1058:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x0e': APPEND_STRING("\\u000e"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1059:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x0f': APPEND_STRING("\\u000f"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1059:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1059:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x0f': APPEND_STRING("\\u000f"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1060:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x10': APPEND_STRING("\\u0010"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1060:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1060:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x10': APPEND_STRING("\\u0010"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1061:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x11': APPEND_STRING("\\u0011"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1061:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1061:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x11': APPEND_STRING("\\u0011"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1062:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x12': APPEND_STRING("\\u0012"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1062:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1062:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x12': APPEND_STRING("\\u0012"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1063:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x13': APPEND_STRING("\\u0013"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1063:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1063:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x13': APPEND_STRING("\\u0013"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1064:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x14': APPEND_STRING("\\u0014"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1064:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1064:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x14': APPEND_STRING("\\u0014"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1065:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x15': APPEND_STRING("\\u0015"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1065:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1065:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x15': APPEND_STRING("\\u0015"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1066:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x16': APPEND_STRING("\\u0016"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1066:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1066:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x16': APPEND_STRING("\\u0016"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1067:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x17': APPEND_STRING("\\u0017"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1067:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1067:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x17': APPEND_STRING("\\u0017"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1068:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x18': APPEND_STRING("\\u0018"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1068:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1068:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x18': APPEND_STRING("\\u0018"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1069:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x19': APPEND_STRING("\\u0019"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1069:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1069:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x19': APPEND_STRING("\\u0019"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1070:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x1a': APPEND_STRING("\\u001a"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1070:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1070:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x1a': APPEND_STRING("\\u001a"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1071:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x1b': APPEND_STRING("\\u001b"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1071:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1071:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x1b': APPEND_STRING("\\u001b"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1072:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x1c': APPEND_STRING("\\u001c"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1072:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1072:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x1c': APPEND_STRING("\\u001c"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1073:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x1d': APPEND_STRING("\\u001d"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1073:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1073:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x1d': APPEND_STRING("\\u001d"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1074:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x1e': APPEND_STRING("\\u001e"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1074:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1074:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x1e': APPEND_STRING("\\u001e"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1075:26: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
            case '\x1f': APPEND_STRING("\\u001f"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1075:26: note: (expanded) expected argument bounds are
      'bounds(buf_start, buf_start + (size_t)buf_len)'
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^
parson.c:1075:26: note: (expanded) inferred bounds are 'bounds(buf_start,
      buf_start + buf_len)'
            case '\x1f': APPEND_STRING("\\u001f"); break;
                         ^~~~~~~~~~~~~~~~~~~~~~~~
parson.c:870:29: note: expanded from macro 'APPEND_STRING'
    written = append_string(buf, (str), buf_start, buf_len);\
                            ^~~
parson.c:1099:52: error: function redeclaration has conflicting parameter bounds
static int append_string(_Nt_array_ptr<char> buf : bounds(buf_start, buf...
                                                   ^
parson.c:159:55: note: previous bounds declaration is here
static int    append_string(_Nt_array_ptr<char> buf : bounds(buf_start, ...
                                                      ^
parson.c:1099:12: error: conflicting types for 'append_string'
static int append_string(_Nt_array_ptr<char> buf : bounds(buf_start, buf...
           ^
parson.c:159:15: note: previous declaration is here
static int    append_string(_Nt_array_ptr<char> buf : bounds(buf_start, ...
              ^
parson.c:1109:5: error: return used in a checked scope must have a checked type
      or a bounds-safe interface
    memcpy<char>(buf, string, len);
    ^
/usr/include/string.h:72:1: note: return declared here
void    *memcpy(void *__dst, const void *__src, size_t __n);
^
parson.c:1408:27: warning: cannot prove argument meets declared bounds for 1st
      parameter [-Wcheck-bounds-decls-checked-scope]
    copy = parson_strndup(tmp, string_len);
                          ^~~
parson.c:1408:27: note: (expanded) expected argument bounds are
      'bounds(tmp, tmp + 0)'
parson.c:1408:27: note: (expanded) inferred bounds are 'bounds(tmp, tmp +
      string_len)'
    copy = parson_strndup(tmp, string_len);
                          ^~~
parson.c:1546:66: warning: cannot prove argument meets declared bounds for 6th
      parameter [-Wcheck-bounds-decls-checked-scope]
    written = json_serialize_to_buffer_r(value, buf, 0, 0, NULL, buf, buf_si...
                                                                 ^~~
parson.c:1546:66: note: (expanded) expected argument bounds are
      'bounds(buf, buf + 0)'
parson.c:1546:66: note: (expanded) inferred bounds are
      'bounds((_Array_ptr<char>)buf, (_Array_ptr<char>)buf + buf_size_in_bytes)'
    written = json_serialize_to_buffer_r(value, buf, 0, 0, NULL, buf, buf_si...
                                                                 ^~~
parson.c:1607:66: warning: cannot prove argument meets declared bounds for 6th
      parameter [-Wcheck-bounds-decls-checked-scope]
    written = json_serialize_to_buffer_r(value, buf, 0, 1, NULL, buf, buf_si...
                                                                 ^~~
parson.c:1607:66: note: (expanded) expected argument bounds are
      'bounds(buf, buf + 0)'
parson.c:1607:66: note: (expanded) inferred bounds are
      'bounds((_Array_ptr<char>)buf, (_Array_ptr<char>)buf + buf_size_in_bytes)'
    written = json_serialize_to_buffer_r(value, buf, 0, 1, NULL, buf, buf_si...
                                                                 ^~~
parson.c:1666:5: error: return used in a checked scope must have a checked type
      or a bounds-safe interface
    memmove<_Ptr<JSON_Value>>(_Dynamic_bounds_cast<_Array_ptr<_Ptr<JSON_...
    ^
/usr/include/string.h:73:1: note: return declared here
void    *memmove(void *__dst, const void *__src, size_t __len);
^
44 warnings and 7 errors generated.
make: *** [compile] Error 1
[ checkedc-parson ]> 

Create and use ctype_checked.h header

We are undefining the isspace macro from ctype.h in the parson code. We should create and use a ctype_checked.h header instead, since anyone using ctype on Linux will run into this problem.

Update code that uses pointers to strings (pointers to pointers to char).

The compiler currently doesn't allow taking the address of any variable that is a string pointer. This is because strings have a default count of 0, and the compiler doesn't allow any variable with a bounds declaration to have its address taken.

This restriction is too severe. It gets in the way of a common pattern of returning updated string values by reference.

void f(_Ptr<_Nt_array_ptr<char>> pstr) {
}

void g(void) {
  _Nt_array_ptr<char> mystr = NULL;
f(&mystr); // compiler error
}

In parson, this causes issues for parse_utf16 and parse_number_value. Once we've addressed in the compiler, we should update the parson code.

There are several possible ways to address the roblem, One possibility is to allow pointer types to have optional bounds declarations that are constant-sized range relatives to the pointer (microsoft/checkedc#173). This is a lot of work, since it requires changing typing rules. Another possibility is to special case _Nt_array_ptr with count(0). referent types in pointers that have constant-sized bounds (a lot of work).

Eliminate unnecesssary _Dynamic_bounds_casts

This is related to #3: there are a number of places where a dynamic bounds cast have been inserted to suppress compiler warning messages. A number of them were because the compiler gives warnings when strings with declared bounds are passed to arguments with default bounds of count(0). We should eliminate these once the compiler is smarter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.