diff options
author | Tao Bao <tbao@google.com> | 2016-11-28 11:48:43 -0800 |
---|---|---|
committer | Tao Bao <tbao@google.com> | 2016-11-28 12:09:39 -0800 |
commit | 358c2ec1dca24d48a503b441d38545ace021ea8e (patch) | |
tree | 433b869340d93bf43ed46916abbcf1cf218e1fb6 /applypatch/applypatch.cpp | |
parent | 3dc14cb429061e49ef76948cf55a0e3edf8b170a (diff) |
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
Diffstat (limited to 'applypatch/applypatch.cpp')
-rw-r--r-- | applypatch/applypatch.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index 0250407a..95389da6 100644 --- a/applypatch/applypatch.cpp +++ b/applypatch/applypatch.cpp @@ -66,7 +66,7 @@ int LoadFileContents(const char* filename, FileContents* file) { } std::vector<unsigned char> data(file->st.st_size); - std::unique_ptr<FILE, int (*)(FILE*)> f(ota_fopen(filename, "rb"), ota_fclose); + unique_file f(ota_fopen(filename, "rb")); if (!f) { printf("failed to open \"%s\": %s\n", filename, strerror(errno)); return -1; @@ -118,7 +118,7 @@ static int LoadPartitionContents(const std::string& filename, FileContents* file std::sort(pairs.begin(), pairs.end()); const char* partition = pieces[1].c_str(); - std::unique_ptr<FILE, int (*)(FILE*)> dev(ota_fopen(partition, "rb"), ota_fclose); + unique_file dev(ota_fopen(partition, "rb")); if (!dev) { printf("failed to open emmc partition \"%s\": %s\n", partition, strerror(errno)); return -1; |