aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu2017-07-10 17:13:33 -0500
committerTianjie Xu2017-07-19 14:17:41 -0500
commitde6735e80cc65be50381388640d94f1b1d0f20fa (patch)
treebdcda7cd5a4e2baa1f45c66f6a1698df47119175 /recovery-persist.cpp
parent8155a8ba74bce27626f3ce3f088951298c44776d (diff)
downloadplatform-bootable-recovery-de6735e80cc65be50381388640d94f1b1d0f20fa.tar.gz
platform-bootable-recovery-de6735e80cc65be50381388640d94f1b1d0f20fa.tar.xz
platform-bootable-recovery-de6735e80cc65be50381388640d94f1b1d0f20fa.zip
Fix the android-cloexec-* warnings in bootable/recovery
Add the O_CLOEXEC or 'e' accordingly. Bug: 63510015 Test: recovery tests pass Change-Id: I7094bcc6af22c9687eb535116b2ca6a59178b303
Diffstat (limited to 'recovery-persist.cpp')
-rw-r--r--recovery-persist.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/recovery-persist.cpp b/recovery-persist.cpp
index d706ccac..dbce7ff7 100644
--- a/recovery-persist.cpp
+++ b/recovery-persist.cpp
@@ -59,21 +59,21 @@ static void check_and_fclose(FILE *fp, const char *name) {
59} 59}
60 60
61static void copy_file(const char* source, const char* destination) { 61static void copy_file(const char* source, const char* destination) {
62 FILE* dest_fp = fopen(destination, "w"); 62 FILE* dest_fp = fopen(destination, "we");
63 if (dest_fp == nullptr) { 63 if (dest_fp == nullptr) {
64 PLOG(ERROR) << "Can't open " << destination; 64 PLOG(ERROR) << "Can't open " << destination;
65 } else { 65 } else {
66 FILE* source_fp = fopen(source, "r"); 66 FILE* source_fp = fopen(source, "re");
67 if (source_fp != nullptr) { 67 if (source_fp != nullptr) {
68 char buf[4096]; 68 char buf[4096];
69 size_t bytes; 69 size_t bytes;
70 while ((bytes = fread(buf, 1, sizeof(buf), source_fp)) != 0) { 70 while ((bytes = fread(buf, 1, sizeof(buf), source_fp)) != 0) {
71 fwrite(buf, 1, bytes, dest_fp); 71 fwrite(buf, 1, bytes, dest_fp);
72 } 72 }
73 check_and_fclose(source_fp, source); 73 check_and_fclose(source_fp, source);
74 }
75 check_and_fclose(dest_fp, destination);
76 } 74 }
75 check_and_fclose(dest_fp, destination);
76 }
77} 77}
78 78
79static bool rotated = false; 79static bool rotated = false;
@@ -120,7 +120,7 @@ int main(int argc, char **argv) {
120 */ 120 */
121 bool has_cache = false; 121 bool has_cache = false;
122 static const char mounts_file[] = "/proc/mounts"; 122 static const char mounts_file[] = "/proc/mounts";
123 FILE *fp = fopen(mounts_file, "r"); 123 FILE* fp = fopen(mounts_file, "re");
124 if (!fp) { 124 if (!fp) {
125 PLOG(ERROR) << "failed to open " << mounts_file; 125 PLOG(ERROR) << "failed to open " << mounts_file;
126 } else { 126 } else {