X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Ftest%2Ftest-fileio.c;h=ad65abf42663e877c49b3b681757ab628a86c3c9;hp=e69706c3f872bd0d7a3ee9f94e0743bb7eb63979;hb=2b01a801f6c597a60a1e622978bf7ac0105b9666;hpb=0709b743749c42f54ffc0d9aeacf7bff45d65af6 diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index e69706c3f..ad65abf42 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -258,7 +258,7 @@ static void test_status_field(void) { assert_se(safe_atollu(s, &buffers) == 0); } - if (p && t) + if (p) assert(buffers < total); /* Seccomp should be a good test for field full of zeros. */ @@ -303,7 +303,7 @@ static void test_write_string_stream(void) { assert_se(f); assert_se(write_string_stream(f, "boohoo") < 0); - f = fdopen(fd, "r+"); + f = freopen(fn, "r+", f); assert_se(f); assert_se(write_string_stream(f, "boohoo") == 0); @@ -317,15 +317,15 @@ static void test_write_string_stream(void) { static void test_write_string_file(void) { char fn[] = "/tmp/test-write_string_file-XXXXXX"; - int fd; - char buf[64] = {0}; + char buf[64] = {}; + _cleanup_close_ int fd; fd = mkostemp_safe(fn, O_RDWR); assert_se(fd >= 0); assert_se(write_string_file(fn, "boohoo") == 0); - assert_se(read(fd, buf, sizeof(buf))); + assert_se(read(fd, buf, sizeof(buf)) == 7); assert_se(streq(buf, "boohoo\n")); unlink(fn); @@ -334,8 +334,7 @@ static void test_write_string_file(void) { static void test_sendfile_full(void) { char in_fn[] = "/tmp/test-sendfile_full-XXXXXX"; char out_fn[] = "/tmp/test-sendfile_full-XXXXXX"; - _cleanup_close_ int in_fd = -1; - int out_fd; + _cleanup_close_ int in_fd, out_fd; char text[] = "boohoo\nfoo\n\tbar\n"; char buf[64] = {0};