summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-24 22:21:28 +0200
committerSven Eden <sven.eden@prydeworx.com>2018-10-29 10:18:39 +0100
commit3a3c3994e958ddbaa5ec6a7a0659245dc8d2b5bc (patch)
treef8d986e3802cc8bf8a618032c6b0df65734be1fe
parentbeed80d1d2042ca36b0555725a226506d77a62b1 (diff)
time-util: change parse_sec_fix_0() to accept "0s" for infinity too (#10501)
This function is about compatibility, nothing else, hence we should make it properly compatible. Fixes: #9556 (cherry picked from commit def34f63fe066c964764733242b332774070bac6)
-rw-r--r--src/basic/time-util.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index 6bd86bf..fce250a 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -1073,18 +1073,19 @@ int parse_sec(const char *t, usec_t *usec) {
}
#if 0 /// UNNEEDED by elogind
-int parse_sec_fix_0(const char *t, usec_t *usec) {
- assert(t);
- assert(usec);
+int parse_sec_fix_0(const char *t, usec_t *ret) {
+ usec_t k;
+ int r;
- t += strspn(t, WHITESPACE);
+ assert(t);
+ assert(ret);
- if (streq(t, "0")) {
- *usec = USEC_INFINITY;
- return 0;
- }
+ r = parse_sec(t, &k);
+ if (r < 0)
+ return r;
- return parse_sec(t, usec);
+ *ret = k == 0 ? USEC_INFINITY : k;
+ return r;
}
int parse_nsec(const char *t, nsec_t *nsec) {