From 4d46b361ff1371a6f3f4f89ed8ca81ee23e86de8 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 6 Nov 2019 11:54:56 +0100 Subject: Remove raw file descriptors from tar read path Signed-off-by: David Oberhollenzer --- tests/tar_xattr_bsd.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/tar_xattr_bsd.c') diff --git a/tests/tar_xattr_bsd.c b/tests/tar_xattr_bsd.c index 36d8ac1..9a7eab2 100644 --- a/tests/tar_xattr_bsd.c +++ b/tests/tar_xattr_bsd.c @@ -21,28 +21,28 @@ #define TEST_PATH STRVALUE(TESTPATH) -static int open_read(const char *path) +static FILE *open_read(const char *path) { - int fd = open(path, O_RDONLY); + FILE *fp = fopen(path, "rb"); - if (fd < 0) { + if (fp == NULL) { perror(path); exit(EXIT_FAILURE); } - return fd; + return fp; } int main(void) { tar_header_decoded_t hdr; char buffer[6]; - int fd; + FILE *fp; assert(chdir(TEST_PATH) == 0); - fd = open_read("xattr/xattr-libarchive.tar"); - assert(read_header(fd, &hdr) == 0); + fp = open_read("xattr/xattr-libarchive.tar"); + assert(read_header(fp, &hdr) == 0); assert(hdr.sb.st_mode == (S_IFREG | 0644)); assert(hdr.sb.st_uid == 01750); assert(hdr.sb.st_gid == 01750); @@ -51,7 +51,7 @@ int main(void) assert(hdr.mtime == 1543094477); assert(strcmp(hdr.name, "input.txt") == 0); assert(!hdr.unknown_record); - assert(read_retry("data0", fd, buffer, 5) == 0); + assert(read_retry("data0", fp, buffer, 5) == 0); buffer[5] = '\0'; assert(strcmp(buffer, "test\n") == 0); @@ -61,6 +61,6 @@ int main(void) assert(hdr.xattr->next == NULL); clear_header(&hdr); - close(fd); + fclose(fp); return EXIT_SUCCESS; } -- cgit v1.2.3