aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests/cmd/largest_file/largest_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/zfs-tests/cmd/largest_file/largest_file.c')
-rw-r--r--tests/zfs-tests/cmd/largest_file/largest_file.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/zfs-tests/cmd/largest_file/largest_file.c b/tests/zfs-tests/cmd/largest_file/largest_file.c
index 1cf7529f1..286232da5 100644
--- a/tests/zfs-tests/cmd/largest_file/largest_file.c
+++ b/tests/zfs-tests/cmd/largest_file/largest_file.c
@@ -64,7 +64,7 @@ main(int argc, char **argv)
offset_t llseek_ret = 0;
int write_ret = 0;
int err = 0;
- char mybuf[5];
+ char mybuf[5] = "aaaa\0";
char *testfile;
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
@@ -78,30 +78,31 @@ main(int argc, char **argv)
fd = open(testfile, O_CREAT | O_RDWR, mode);
if (fd < 0) {
- perror("Failed to create testfile");
err = errno;
- goto out;
+ perror("Failed to create testfile");
+ free(testfile);
+ return (err);
}
llseek_ret = lseek64(fd, offset, SEEK_SET);
if (llseek_ret < 0) {
- perror("Failed to seek to end of testfile");
err = errno;
+ perror("Failed to seek to end of testfile");
goto out;
}
write_ret = write(fd, mybuf, 1);
if (write_ret < 0) {
- perror("Failed to write to end of file");
err = errno;
+ perror("Failed to write to end of file");
goto out;
}
offset = 0;
llseek_ret = lseek64(fd, offset, SEEK_CUR);
if (llseek_ret < 0) {
- perror("Failed to seek to end of file");
err = errno;
+ perror("Failed to seek to end of file");
goto out;
}
@@ -111,8 +112,8 @@ main(int argc, char **argv)
(void) printf("write errno=EFBIG: success\n");
err = 0;
} else {
- perror("Did not receive EFBIG");
err = errno;
+ perror("Did not receive EFBIG");
}
} else {
(void) printf("write completed successfully, test failed\n");
@@ -122,6 +123,7 @@ main(int argc, char **argv)
out:
(void) unlink(testfile);
free(testfile);
+ close(fd);
return (err);
}