Message ID | 20230222214941.118075-1-deborah.brouwer@collabora.com |
---|---|
State | New |
Headers | show |
Series | [v2] v4l2-tracer: remove trailing comma from JSON trace | expand |
diff --git a/utils/v4l2-tracer/v4l2-tracer.cpp b/utils/v4l2-tracer/v4l2-tracer.cpp index ae6f68e4..cb873d83 100644 --- a/utils/v4l2-tracer/v4l2-tracer.cpp +++ b/utils/v4l2-tracer/v4l2-tracer.cpp @@ -345,8 +345,8 @@ int tracer(int argc, char *argv[], bool retrace) fprintf(stderr, "Tracee exited with status: %d\n", exec_result); /* Close the json-array and the trace file. */ - trace_file = fopen(trace_filename.c_str(), "a"); - fseek(trace_file, 0L, SEEK_END); + trace_file = fopen(trace_filename.c_str(), "r+"); + fseek(trace_file, -2L, SEEK_END); fputs("\n]\n", trace_file); fclose(trace_file);
Put the trace file into valid JSON format by removing the trailing comma from the trace file array. Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com> --- Changes since v1: - open file in "r+" and use fseek instead of ftruncate utils/v4l2-tracer/v4l2-tracer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)