diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-03-27 09:18:50 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-03-27 11:52:54 +0100 |
commit | b45556375e0b9989a1245a36fcb673b95eb21f43 (patch) | |
tree | e83fbe9c419ff5e0c9b667d43c261bbff642021b /src/test | |
parent | Merge pull request #12109 from poettering/sleep-minifixes (diff) | |
download | systemd-b45556375e0b9989a1245a36fcb673b95eb21f43.tar.xz systemd-b45556375e0b9989a1245a36fcb673b95eb21f43.zip |
test-fileio: do not use variable before checking return value
Coverity is unhappy because we use "line" in the assert that checks
the return value. It doesn't matter much, but let's clean this up.
Also, let's not assume that /proc/cmdline contains anything.
CID #1400219.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-fileio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index 3dd4287ff0..2ff5b9a69d 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -759,7 +759,11 @@ static void test_read_line3(void) { assert_se(f); r = read_line(f, LINE_MAX, &line); - assert_se((size_t) r == strlen(line) + 1); + assert_se(r >= 0); + if (r == 0) + assert_se(line && isempty(line)); + else + assert_se((size_t) r == strlen(line) + 1); assert_se(read_line(f, LINE_MAX, NULL) == 0); } |