diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-10-24 19:10:09 +0200 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-10-25 14:12:42 -0400 |
commit | 53f0b01f222756c6e32966a9ede3d30b2cfd2d1a (patch) | |
tree | ce1481471619a4e639d26e0b6f646f6a13ca2f22 | |
parent | d9c4f21a139e999f25a68ec9742350efe6d1ad06 (diff) |
time: don't do comparison twice
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-rw-r--r-- | src/shared/time-util.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/shared/time-util.c b/src/shared/time-util.c index 4e12ea3ca6..3f72fdd5b2 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -99,8 +99,14 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) { assert(buf); assert(l > 0); - if (t == USEC_INFINITY || t <= 0) { - strncpy(p, t == USEC_INFINITY ? "infinity" : "0", l); + if (t == USEC_INFINITY) { + strncpy(p, "infinity", l-1); + p[l-1] = 0; + return p; + } + + if (t <= 0) { + strncpy(p, "0", l-1); p[l-1] = 0; return p; } |