Make the JSON code easier to analyze
authorBart Van Assche <bvanassche@acm.org>
Wed, 5 Feb 2020 05:18:31 +0000 (21:18 -0800)
committerBart Van Assche <bvanassche@acm.org>
Thu, 6 Feb 2020 03:04:38 +0000 (19:04 -0800)
commiteb2f29b7fd9c889a8d30600acbe10cf440eba394
tree7335b8ae11616ea961921c7869adf8872691361f
parentac694f66968fe7b18c820468abd8333f3df333fb
Make the JSON code easier to analyze

Coverity reports the following false positive for the JSON code in stat.c:

CID 284826 (#1 of 1): Resource leak (RESOURCE_LEAK)
17. leaked_storage: Variable percentile_object going out of scope leaks the storage it points to.

Suppress this false positive by making the JSON code easier to analyze. The
changes in this patch are as follows:
- Change the macros in json.h into inline functions such that the compiler
  performs argument type verification at compile time.
- Pass a struct json_value pointer to json_*_add_value_type() instead of
  using varargs.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
json.c
json.h
stat.c