[systemd-commits] 2 commits - src/shared src/test
Daniel Mack
zonque at kemper.freedesktop.org
Tue Feb 24 04:27:58 PST 2015
src/shared/time-util.c | 2 +-
src/test/test-time.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
New commits:
commit fdd30a1530810b659345c565e97beef06b7af2fd
Author: Daniel Mack <daniel at zonque.org>
Date: Tue Feb 24 13:27:10 2015 +0100
test-time: test "infinity" parsing in nanoseconds
diff --git a/src/test/test-time.c b/src/test/test-time.c
index 8cfc4cc..3840fff 100644
--- a/src/test/test-time.c
+++ b/src/test/test-time.c
@@ -78,12 +78,18 @@ static void test_parse_nsec(void) {
assert_se(u == 2);
assert_se(parse_nsec(".7", &u) >= 0);
assert_se(u == 0);
+ assert_se(parse_nsec("infinity", &u) >= 0);
+ assert_se(u == NSEC_INFINITY);
+ assert_se(parse_nsec(" infinity ", &u) >= 0);
+ assert_se(u == NSEC_INFINITY);
assert_se(parse_nsec(" xyz ", &u) < 0);
assert_se(parse_nsec("", &u) < 0);
assert_se(parse_nsec(" . ", &u) < 0);
assert_se(parse_nsec(" 5. ", &u) < 0);
assert_se(parse_nsec(".s ", &u) < 0);
+ assert_se(parse_nsec(" infinity .7", &u) < 0);
+ assert_se(parse_nsec(".3 infinity", &u) < 0);
}
static void test_format_timespan_one(usec_t x, usec_t accuracy) {
commit 8e8933ca0f06bae19cb6db601e83b33f8ac80f2a
Author: Daniel Mack <daniel at zonque.org>
Date: Tue Feb 24 13:26:09 2015 +0100
shared/time-util: fix gcc5 warning
CC src/shared/libsystemd_shared_la-time-util.lo
src/shared/time-util.c: In function 'parse_nsec':
src/shared/time-util.c:789:25: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
if (!*s != 0)
^
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index 947ac1f..1c36c57 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -786,7 +786,7 @@ int parse_nsec(const char *t, nsec_t *nsec) {
s = startswith(p, "infinity");
if (s) {
s += strspn(s, WHITESPACE);
- if (!*s != 0)
+ if (*s != 0)
return -EINVAL;
*nsec = NSEC_INFINITY;
More information about the systemd-commits
mailing list