Commit 2fff1d93 authored by Felix Eckhofer's avatar Felix Eckhofer 🤹🏼

Simplify timespan formatting

This makes sure the logfile mostly lines up nicely and removes some
unnecessary logic from `format_seconds`
parent d960b223
......@@ -439,8 +439,6 @@ static void format_seconds(long seconds, char buf[], size_t nbuf)
{
long minutes = 0;
long hours = 0;
size_t len = 0;
char* target = buf;
if (seconds >= 60) {
minutes = seconds / 60;
......@@ -452,21 +450,7 @@ static void format_seconds(long seconds, char buf[], size_t nbuf)
}
}
if (hours > 0) {
snprintf(target, nbuf, "%ld:", hours);
len = strlen(target);
target += len;
nbuf -= len;
}
if (hours > 0 || minutes > 0) {
snprintf(target, nbuf, "%02ld:", minutes);
len = strlen(target);
target += len;
nbuf -= len;
}
snprintf(target, nbuf, "%02ld", seconds);
snprintf(buf, nbuf, "%ld:%02ld:%02ld", hours, minutes, seconds);
}
/* write a spin-up event message to the log file */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment