ART: Fix android-cloexec warnings
Use the DupCloexec helper wherever possible. Add O_CLOEXEC to open
and fopen calls.
Bug: 32619234
Test: WITH_TIDY=1 mmma art
Change-Id: I0afb1beea53ab8f68ab85d1762aff999903060fe
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index 3a974df..aba2eae 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -338,9 +338,9 @@
CompilerFilter::kSpeed,
/* with_alternate_image */ false);
- android::base::unique_fd odex_fd(open(odex_location.c_str(), O_RDONLY));
- android::base::unique_fd vdex_fd(open(vdex_location.c_str(), O_RDONLY));
- android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY));
+ android::base::unique_fd odex_fd(open(odex_location.c_str(), O_RDONLY | O_CLOEXEC));
+ android::base::unique_fd vdex_fd(open(vdex_location.c_str(), O_RDONLY | O_CLOEXEC));
+ android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY | O_CLOEXEC));
OatFileAssistant oat_file_assistant(dex_location.c_str(),
kRuntimeISA,
@@ -377,8 +377,8 @@
CompilerFilter::kSpeed,
/* with_alternate_image */ false);
- android::base::unique_fd vdex_fd(open(vdex_location.c_str(), O_RDONLY));
- android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY));
+ android::base::unique_fd vdex_fd(open(vdex_location.c_str(), O_RDONLY | O_CLOEXEC));
+ android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY | O_CLOEXEC));
OatFileAssistant oat_file_assistant(dex_location.c_str(),
kRuntimeISA,
@@ -410,8 +410,8 @@
CompilerFilter::kSpeed,
/* with_alternate_image */ false);
- android::base::unique_fd odex_fd(open(odex_location.c_str(), O_RDONLY));
- android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY));
+ android::base::unique_fd odex_fd(open(odex_location.c_str(), O_RDONLY | O_CLOEXEC));
+ android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY | O_CLOEXEC));
OatFileAssistant oat_file_assistant(dex_location.c_str(),
kRuntimeISA,
@@ -436,7 +436,7 @@
Copy(GetDexSrc1(), dex_location);
- android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY));
+ android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY | O_CLOEXEC));
OatFileAssistant oat_file_assistant(dex_location.c_str(),
kRuntimeISA,
false,