summaryrefslogtreecommitdiff
path: root/src/test/test-fileio.c
diff options
context:
space:
mode:
authorRonny Chevalier <chevalier.ronny@gmail.com>2014-09-18 12:09:10 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-09-18 12:09:10 +0200
commit76082570b8115c3410bac42bb5842ba201dddb76 (patch)
tree160630566b609aeb126986d77330976ba9182078 /src/test/test-fileio.c
parent913b6d70cbfd6151babc77ffc5e8c67b953ddba9 (diff)
tests: fix resource & mem leaks
Diffstat (limited to 'src/test/test-fileio.c')
-rw-r--r--src/test/test-fileio.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 92aa794a95..1b99828191 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};