From: Lennart Poettering Date: Fri, 6 Aug 2010 19:33:53 +0000 (+0200) Subject: util: when formatting timestamps return '0' for 0 timestamps instead of empty string X-Git-Tag: v7~18 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4502d22cb8a96d9059b02861b8074e4fadf2cab2;p=systemd util: when formatting timestamps return '0' for 0 timestamps instead of empty string --- diff --git a/src/util.c b/src/util.c index ee7749be..7281b703 100644 --- a/src/util.c +++ b/src/util.c @@ -1936,6 +1936,12 @@ char *format_timespan(char *buf, size_t l, usec_t t) { if (t == (usec_t) -1) return NULL; + if (t == 0) { + snprintf(p, l, "0"); + p[l-1] = 0; + return p; + } + /* The result of this function can be parsed with parse_usec */ for (i = 0; i < ELEMENTSOF(table); i++) {