char in_fn[] = "/tmp/test-copy-file-fd-XXXXXX";
char out_fn[] = "/tmp/test-copy-file-fd-XXXXXX";
_cleanup_close_ int in_fd = -1, out_fd = -1;
- char text[] = "boohoo\nfoo\n\tbar\n";
- char buf[64] = {0};
+ const char *text = "boohoo\nfoo\n\tbar\n";
+ char buf[64] = {};
log_info("%s", __func__);
assert_se(copy_file_fd(in_fn, out_fd, COPY_REFLINK) >= 0);
assert_se(lseek(out_fd, SEEK_SET, 0) == 0);
- assert_se(read(out_fd, buf, sizeof(buf)) == sizeof(text) - 1);
+ assert_se(read(out_fd, buf, sizeof buf) == (ssize_t) strlen(text));
assert_se(streq(buf, text));
unlink(in_fn);
static void test_write_string_file_no_create(void) {
_cleanup_(unlink_tempfilep) char fn[] = "/tmp/test-write_string_file_no_create-XXXXXX";
_cleanup_close_ int fd;
- char buf[64] = {0};
+ char buf[64] = {};
fd = mkostemp_safe(fn);
assert_se(fd >= 0);
assert_se(write_string_file("/a/file/which/does/not/exists/i/guess", "boohoo", 0) < 0);
assert_se(write_string_file(fn, "boohoo", 0) == 0);
- assert_se(read(fd, buf, sizeof(buf)) == STRLEN("boohoo\n"));
+ assert_se(read(fd, buf, sizeof buf) == (ssize_t) strlen("boohoo\n"));
assert_se(streq(buf, "boohoo\n"));
}