From: Zbigniew Jędrzejewski-Szmek Date: Wed, 27 Mar 2019 08:18:50 +0000 (+0100) Subject: test-fileio: do not use variable before checking return value X-Git-Tag: v242-rc1~55^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b45556375e0b9989a1245a36fcb673b95eb21f43;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index 3dd4287ff0f..2ff5b9a69d5 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); }