path: root/json.h
AgeCommit message (Collapse)Author
2020-05-24Make json_object_add_value_string() duplicate its 'value' argumentBart Van Assche
Having some json_object_add_value_string() callers duplicate the 'value' argument others not is dubious because it can lead to dangling pointers, e.g. when passing strings to json_object_add_value_string() that live less long than the created JSON object. See e.g. the 'time_buf' stack array that is passed by fio_client_json_init() to json_object_add_value_string(). Signed-off-by: Bart Van Assche <>
2020-04-22json: Fix compile error on RHEL6Tomohiro Kusumi
eb2f29b7fd("Make the JSON code easier to analyze") doesn't compile on RHEL6 using gcc4.x. Using "{.object = val,}," for an union field seems to fix the issue, but just use "arg.object = val;" instead as this is guaranteed to compile on supported platforms. -- CC gettime.o In file included from stat.h:7, from thread_options.h:7, from fio.h:18, from gettime.c:7: json.h: In function 'json_object_add_value_object': json.h:95: error: unknown field 'object' specified in initializer json.h:95: warning: missing braces around initializer json.h:95: warning: (near initialization for 'arg.<anonymous>') json.h:95: warning: initialization makes integer from pointer without a cast make: *** [gettime.o] Error 1 Signed-off-by: Tomohiro Kusumi <>
2020-04-20json: don't use named initializers for anonymous unionsJens Axboe
Older compilers don't like it, and we can just do make it work a bit differently instead. Fixes: Signed-off-by: Jens Axboe <>
2020-02-05Make the JSON code easier to analyzeBart Van Assche
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 <>
2018-03-21Refactor #includes and headersSitsofe Wheeler
- Try and remove unneeded #include lines - Try and add #include lines that would allow the files to be built in a more standalone manner Signed-off-by: Sitsofe Wheeler <>
2015-10-27Enable the use of multiple output formatsJens Axboe
You can now do ./fio --output-format=normal,json jobfile.fio and get both types of output. Signed-off-by: Jens Axboe <>
2014-06-24Cast input argument for json_object_add_value_int to long longPuthikorn Voravootivat
The latency related (and some other) variables type is uint32_t but the JSON integer type is long long. So we need to cast the numbers to long long type to make JSON output correctly. Signed-off-by: Puthikorn Voravootivat <> Signed-off-by: Jens Axboe <>
2014-04-03Fix JSON_INTEGER overflow on Windows by changing datatype to 'long long'Bruce Cran
Signed-off-by: Jens Axboe <>
2013-10-31Add json output for client/server modeCastor Fu
In client/server mode, this adds support for json mode. Each job's details are gradually accumulated and upon completion the client dumps the full json tree. The tree is annotated with the server host and port. Signed-off-by: Castor Fu <> Signed-off-by: Jens Axboe <>
2012-09-17Add a simple json encoder and use it to print fio output in json formatShaohua Li
Signed-off-by: Jens Axboe <>