]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-fileio: do not use variable before checking return value
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 27 Mar 2019 08:18:50 +0000 (09:18 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 27 Mar 2019 10:52:54 +0000 (11:52 +0100)
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.

src/test/test-fileio.c

index 3dd4287ff0f4263080b57b56a34699caa7ab57f9..2ff5b9a69d5e5da3bd81578b42179e72f6863f13 100644 (file)
@@ -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);
 }