@@ -1778,12 +1778,13 @@ static void write_stats(FILE *f, void *data __attribute__ ((unused)))
fprintf(f, " \"resolution_in_ns\": %u,\n", use_nsecs);
fprintf(f, " \"thread\": {\n");
for (i = 0; i < num_threads; i++) {
- fprintf(f, " \"%u\": {\n", i);
-
- fprintf(f, " \"histogram\": {");
s = par[i]->stats;
- hist_print_json(par[i]->stats->hist, f);
- fprintf(f, " },\n");
+ fprintf(f, " \"%u\": {\n", i);
+ if (s->hist) {
+ fprintf(f, " \"histogram\": {");
+ hist_print_json(s->hist, f);
+ fprintf(f, " },\n");
+ }
fprintf(f, " \"cycles\": %ld,\n", s->cycles);
fprintf(f, " \"min\": %ld,\n", s->min);
fprintf(f, " \"max\": %ld,\n", s->max);
@@ -1141,10 +1141,11 @@ static void write_stats(FILE *f, void *data)
for (i = 0; i < nr_threads; i++) {
s = &sd[i].stat;
fprintf(f, " \"%u\": {\n", i);
-
- fprintf(f, " \"histogram\": {");
- hist_print_json(s->hist, f);
- fprintf(f, " },\n");
+ if (s->hist) {
+ fprintf(f, " \"histogram\": {");
+ hist_print_json(s->hist, f);
+ fprintf(f, " },\n");
+ }
fprintf(f, " \"cycles\": %ld,\n", s->cycles);
fprintf(f, " \"min\": %ld,\n", s->min);
fprintf(f, " \"max\": %ld,\n", s->max);
If we're not generating a histogram, don't call the histogram code with a NULL pointer. Also don't print the rest of the histogram json node. Signed-off-by: Crystal Wood <crwood@redhat.com> --- src/cyclictest/cyclictest.c | 11 ++++++----- src/sched_deadline/cyclicdeadline.c | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-)