X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftest%2Ftest-fileio.c;h=1b998281912543a927ad00fa42997881d291a523;hb=c2fa048c4a70c8386c6d8fe939e5ea9edecf1e98;hp=92aa794a9513a094b7eee19e2763bf5963acc36e;hpb=cca0efb0477f9bb7d61b48ba270b885b29c0bb72;p=elogind.git diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index 92aa794a9..1b9982819 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -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,8 +317,8 @@ 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); @@ -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};