From: Sebastien GODARD Date: Tue, 13 Sep 2022 14:42:27 +0000 (+0200) Subject: SVG: Fix timestamps displayed in true time mode X-Git-Tag: v12.7.1~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b99f664ab31c90b8fe52ee83c1f47b8fb0230f7;p=sysstat SVG: Fix timestamps displayed in true time mode 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 --- diff --git a/svg_stats.c b/svg_stats.c index e9c4484..0ebf1ed 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -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; } }