chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sleep-config: fix useless check for swapfile type
[elogind.git]
/
src
/
shared
/
time-util.c
diff --git
a/src/shared/time-util.c
b/src/shared/time-util.c
index b29d8c6e4ee710cbba2e3e4512786001ea7c2eb6..faa3418819e81dfe4e526966bac34554425cad68 100644
(file)
--- 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;
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;
}
return tv;
}
@@
-158,7
+157,7
@@
char *format_timestamp(char *buf, size_t l, usec_t t) {
assert(buf);
assert(l > 0);
assert(buf);
assert(l > 0);
- if (t <= 0)
+ if (t <= 0
|| t == (usec_t) -1
)
return NULL;
sec = (time_t) (t / USEC_PER_SEC);
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);
assert(buf);
assert(l > 0);
- if (t <= 0)
+ if (t <= 0
|| t == (usec_t) -1
)
return NULL;
sec = (time_t) (t / USEC_PER_SEC);
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);
assert(value);
assert(t);
- if (sscanf(value, "%ll
i
%llu", &a, &b) != 2)
+ if (sscanf(value, "%ll
u
%llu", &a, &b) != 2)
log_debug("Failed to parse finish timestamp value %s", value);
else {
t->realtime = a;
log_debug("Failed to parse finish timestamp value %s", value);
else {
t->realtime = a;