X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Ftime-util.c;h=faa3418819e81dfe4e526966bac34554425cad68;hb=127b55d5a49e8e534e12107fc5d5a684c390d7aa;hp=b29d8c6e4ee710cbba2e3e4512786001ea7c2eb6;hpb=1fcf71f562a83a59f853f982306fca7d009bb30d;p=elogind.git diff --git a/src/shared/time-util.c b/src/shared/time-util.c index b29d8c6e4..faa341881 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -142,12 +142,11 @@ struct timeval *timeval_store(struct timeval *tv, usec_t u) { if (u == (usec_t) -1) { tv->tv_sec = (time_t) -1; tv->tv_usec = (suseconds_t) -1; - return tv; + } else { + tv->tv_sec = (time_t) (u / USEC_PER_SEC); + tv->tv_usec = (suseconds_t) (u % USEC_PER_SEC); } - tv->tv_sec = (time_t) (u / USEC_PER_SEC); - tv->tv_usec = (suseconds_t) (u % USEC_PER_SEC); - return tv; } @@ -158,7 +157,7 @@ char *format_timestamp(char *buf, size_t l, usec_t t) { assert(buf); assert(l > 0); - if (t <= 0) + if (t <= 0 || t == (usec_t) -1) return NULL; sec = (time_t) (t / USEC_PER_SEC); @@ -176,7 +175,7 @@ char *format_timestamp_us(char *buf, size_t l, usec_t t) { assert(buf); assert(l > 0); - if (t <= 0) + if (t <= 0 || t == (usec_t) -1) return NULL; sec = (time_t) (t / USEC_PER_SEC); @@ -383,7 +382,7 @@ void dual_timestamp_deserialize(const char *value, dual_timestamp *t) { assert(value); assert(t); - if (sscanf(value, "%lli %llu", &a, &b) != 2) + if (sscanf(value, "%llu %llu", &a, &b) != 2) log_debug("Failed to parse finish timestamp value %s", value); else { t->realtime = a;