]> granicus.if.org Git - sysstat/commitdiff
SVG: Fix timestamps displayed in true time mode
authorSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 13 Sep 2022 14:42:27 +0000 (16:42 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 13 Sep 2022 14:42:27 +0000 (16:42 +0200)
Hours, minutes and seconds are saved as 8-bit values in structure
record_header. This is not enough to avoid a possible overflow when
calculating X-axis graduations.

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

index e9c4484e117726dea1b051d29de818a71153a46a..0ebf1ed802c210782ecbb386006de8a6b2bb1025 100644 (file)
@@ -566,13 +566,17 @@ void compute_next_graduation_timestamp(struct record_header *stamp, long int xpo
        stamp->ust_time += xpos;
 
        if (PRINT_TRUE_TIME(flags)) {
+               unsigned int h = stamp->hour,
+                            m = stamp->minute,
+                            s = stamp->second;
+
                /* Lines below useful only when option -t used */
-               stamp->second += xpos;
-               stamp->minute += stamp->second / 60;
-               stamp->second %= 60;
-               stamp->hour += stamp->minute / 60;
-               stamp->minute %= 60;
-               stamp->hour %= 24;
+               s += xpos;
+               m += s / 60;
+               stamp->second = s % 60;
+               h += m / 60;
+               stamp->minute = m % 60;
+               stamp->hour = h % 24;
        }
 }