]> err.no Git - systemd/commitdiff
util: when formatting timestamps return '0' for 0 timestamps instead of empty string
authorLennart Poettering <lennart@poettering.net>
Fri, 6 Aug 2010 19:33:53 +0000 (21:33 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 6 Aug 2010 19:34:11 +0000 (21:34 +0200)
src/util.c

index ee7749be5ef9c4751acdb4bc3ffcf8de64890dd7..7281b703abbd5a63ef230f63dfe4f20c349c59a6 100644 (file)
@@ -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++) {