summaryrefslogtreecommitdiff
path: root/src/test/test-fileio.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-03-27 09:18:50 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-03-27 11:52:54 +0100
commitb45556375e0b9989a1245a36fcb673b95eb21f43 (patch)
treee83fbe9c419ff5e0c9b667d43c261bbff642021b /src/test/test-fileio.c
parenta1917c55c303c28779ed5656eaf4082ac4e6b03a (diff)
downloadsystemd-b45556375e0b9989a1245a36fcb673b95eb21f43.tar.gz
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/test-fileio.c')
-rw-r--r--src/test/test-fileio.c6
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);
}