From 4a8fde00596c0b07f8c9da98959da1b99b6c4fbe Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Fri, 19 Feb 2016 14:38:36 +0100 Subject: [PATCH] SVG: Handle files with orphan samples properly If a file has only orphan samples then display "No data" indicating that the graph cannot be drawn. An orphan sample is something like: sadc data <-- LINUX RESTART sadc data 1 1 <-- Create an orphan sample sadc data <-- LINUX RESTART Signed-off-by: Sebastien GODARD --- svg_stats.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/svg_stats.c b/svg_stats.c index 829089f..35485c7 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -379,8 +379,12 @@ __print_funct_t svg_print_pcsw_stats(struct activity *a, int curr, int action, s 5 + SVG_M_XSIZE + SVG_G_XSIZE, 25 + i * SVG_T_YSIZE); - /* At least two samples are needed */ - if (record_hdr->ust_time == svg_p->record_hdr->ust_time) { + /* + * At least two samples are needed. + * And a min and max value should have been found. + */ + if ((record_hdr->ust_time == svg_p->record_hdr->ust_time) || + (*(spmin + i) == DBL_MAX) || (*(spmax + i) == -DBL_MIN)) { /* No data found */ printf("No data\n", SVG_M_YSIZE + i * SVG_T_YSIZE); -- 2.40.0