]> granicus.if.org Git - sysstat/commitdiff
SVG: Make sure that "No data" is displayed when no graphs are created
authorSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 7 Feb 2018 10:36:16 +0000 (11:36 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 7 Feb 2018 10:38:27 +0000 (11:38 +0100)
If no graphs are detected (e.g. the file contains only a LINUX RESTART
message) then SVG file is empty and an error is displayed by the browser.
Make sure that "No data" is displayed in the browser window instead.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sadf.c

diff --git a/sadf.c b/sadf.c
index 396d2095d8daecc770e360274b76f204f3e1f445..82ac15f4a2a6e312221ce562df4eb535fee9f18a 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -447,6 +447,7 @@ void seek_file_position(int ifd, int action)
  * RETURNS:
  * Number of rows containing views, taking into account only activities
  * to be displayed, and selected period of time (options -s/-e).
+ * Result may be 0.
  ***************************************************************************
  */
 int get_svg_graph_nr(int ifd, char *file, struct file_magic *file_magic,
@@ -1221,21 +1222,21 @@ void logic3_display_loop(int ifd, struct file_activity *file_actlst,
        /* Use a decimal point to make SVG code locale independent */
        setlocale(LC_NUMERIC, "C");
 
-       /* Calculate the number of rows and the max number of views per row to display */
+       /*
+        * Calculate the number of rows and the max number of views per row to display.
+        * Result may be 0. In this case, "No data" will be displayed instead of the graphs.
+        */
        graph_nr = get_svg_graph_nr(ifd, file, file_magic,
                                    file_actlst, rectime, loctime, &views_per_row);
 
        if (SET_CANVAS_HEIGHT(flags)) {
                /*
-                * Option "-O height=..." used: This is not a number
+                * Option "-O height=..." used: @graph_nr is NO LONGER a number
                 * of graphs but the SVG canvas height set on the command line.
                 */
                graph_nr = canvas_height;
        }
 
-       if (!graph_nr)
-               /* No graph to display */
-               return;
 
        parm.graph_nr = graph_nr;
        parm.views_per_row = PACK_VIEWS(flags) ? views_per_row : 1;