From 358c2ec1dca24d48a503b441d38545ace021ea8e Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 28 Nov 2016 11:48:43 -0800 Subject: Remove ota_close(int) and ota_fclose(FILE*). We should always use unique_fd or unique_file to hold the FD or FILE* pointer when opening via ota_(f)open functions. This CL avoids accidentally closing raw FDs or FILE* pointers that are managed by unique_fd/unique_file. Test: recovery_component_test passes. Change-Id: If58eb8b5c5da507563f85efd5d56276472a1c957 --- otafault/ota_io.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'otafault/ota_io.h') diff --git a/otafault/ota_io.h b/otafault/ota_io.h index 45d17b1bb..395b4230e 100644 --- a/otafault/ota_io.h +++ b/otafault/ota_io.h @@ -40,10 +40,6 @@ int ota_open(const char* path, int oflags, mode_t mode); FILE* ota_fopen(const char* filename, const char* mode); -int ota_close(int fd); - -int ota_fclose(FILE* fh); - size_t ota_fread(void* ptr, size_t size, size_t nitems, FILE* stream); ssize_t ota_read(int fd, void* buf, size_t nbyte); @@ -55,15 +51,19 @@ ssize_t ota_write(int fd, const void* buf, size_t nbyte); int ota_fsync(int fd); struct OtaCloser { - static void Close(int fd) { - ota_close(fd); - } + static void Close(int); }; using unique_fd = android::base::unique_fd_impl; int ota_close(unique_fd& fd); -int ota_fclose(std::unique_ptr& fh); +struct OtaFcloser { + void operator()(FILE*); +}; + +using unique_file = std::unique_ptr; + +int ota_fclose(unique_file& fh); #endif -- cgit v1.2.3