chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
random-util: always cast from smaller to bigger type when comparing
[elogind.git]
/
src
/
basic
/
time-util.c
diff --git
a/src/basic/time-util.c
b/src/basic/time-util.c
index 7da7ea41c1a632e5896eec40eebbb6dc845e1b8b..397637f53b561e757ec3076fde92f6e29b2a549c 100644
(file)
--- a/
src/basic/time-util.c
+++ b/
src/basic/time-util.c
@@
-860,19
+860,23
@@
parse_usec:
from_tm:
x = mktime_or_timegm(&tm, utc);
from_tm:
x = mktime_or_timegm(&tm, utc);
- if (x
< 0
)
- return -E
INVAL
;
+ if (x
== (time_t) -1
)
+ return -E
OVERFLOW
;
if (weekday >= 0 && tm.tm_wday != weekday)
return -EINVAL;
if (weekday >= 0 && tm.tm_wday != weekday)
return -EINVAL;
- ret = (usec_t) x * USEC_PER_SEC + x_usec;
+ if (x < 0)
+ ret = 0;
+ else
+ ret = (usec_t) x * USEC_PER_SEC + x_usec;
+
if (ret > USEC_TIMESTAMP_FORMATTABLE_MAX)
return -EINVAL;
finish:
if (ret + plus < ret) /* overflow? */
if (ret > USEC_TIMESTAMP_FORMATTABLE_MAX)
return -EINVAL;
finish:
if (ret + plus < ret) /* overflow? */
- return -E
INVAL
;
+ return -E
OVERFLOW
;
ret += plus;
if (ret > USEC_TIMESTAMP_FORMATTABLE_MAX)
return -EINVAL;
ret += plus;
if (ret > USEC_TIMESTAMP_FORMATTABLE_MAX)
return -EINVAL;
@@
-1024,6
+1028,16
@@
int parse_sec(const char *t, usec_t *usec) {
}
#if 0 /// UNNEEDED by elogind
}
#if 0 /// UNNEEDED by elogind
+int parse_sec_fix_0(const char *t, usec_t *usec) {
+ t += strspn(t, WHITESPACE);
+ if (streq(t, "0")) {
+ *usec = USEC_INFINITY;
+ return 0;
+ }
+
+ return parse_sec(t, usec);
+}
+
int parse_nsec(const char *t, nsec_t *nsec) {
static const struct {
const char *suffix;
int parse_nsec(const char *t, nsec_t *nsec) {
static const struct {
const char *suffix;