From: Sebastien GODARD Date: Fri, 19 Feb 2016 13:38:36 +0000 (+0100) Subject: SVG: Handle files with orphan samples properly X-Git-Tag: v11.3.1~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a8fde00596c0b07f8c9da98959da1b99b6c4fbe;p=sysstat 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 --- 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);