summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2023-02-10 19:42:31 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-02-10 19:42:31 +0000
commitcc45fbdab7d53feb9038caf409d475893e54015e (patch)
tree883046638e5b5a5923f4c80b1965cb59c830f641
parentc0f1bd4f8052dd109db320239ec6990326719e69 (diff)
parent6f3bd5ed9b7a4bb80e3d7f8eb6164f8ff0e491b0 (diff)
downloadunwinding-cc45fbdab7d53feb9038caf409d475893e54015e.tar.gz
Add e to all fopen calls. am: 6f3bd5ed9b
Original change: https://android-review.googlesource.com/c/platform/system/unwinding/+/2429572 Change-Id: I9e6fcd3673c989d4fedd4fb2856a4bfba517ed81 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--libunwindstack/tools/unwind_for_offline.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/libunwindstack/tools/unwind_for_offline.cpp b/libunwindstack/tools/unwind_for_offline.cpp
index 20c88b7..9184665 100644
--- a/libunwindstack/tools/unwind_for_offline.cpp
+++ b/libunwindstack/tools/unwind_for_offline.cpp
@@ -89,7 +89,7 @@ bool CreateAndChangeDumpDir(std::filesystem::path thread_dir, pid_t tid, bool is
}
bool SaveRegs(unwindstack::Regs* regs) {
- std::unique_ptr<FILE, decltype(&fclose)> fp(fopen("regs.txt", "w+"), &fclose);
+ std::unique_ptr<FILE, decltype(&fclose)> fp(fopen("regs.txt", "we+"), &fclose);
if (fp == nullptr) {
perror("Failed to create file regs.txt");
return false;
@@ -123,7 +123,7 @@ bool SaveStack(pid_t tid, const std::vector<std::pair<uint64_t, uint64_t>>& stac
fprintf(output_fp, "\nSaving the stack 0x%" PRIx64 "-0x%" PRIx64 "\n", sp_start, sp_end);
- std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(file_name.c_str(), "w+"), &fclose);
+ std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(file_name.c_str(), "we+"), &fclose);
if (fp == nullptr) {
perror("Failed to create stack.data");
return false;
@@ -150,13 +150,13 @@ bool SaveStack(pid_t tid, const std::vector<std::pair<uint64_t, uint64_t>>& stac
bool CopyElf(unwindstack::MapInfo* map_info, std::string* name) {
std::string cur_name = android::base::Basename(map_info->name());
- std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(map_info->name().c_str(), "r"), &fclose);
+ std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(map_info->name().c_str(), "re"), &fclose);
if (fp == nullptr) {
perror((std::string("Cannot open ") + map_info->name().c_str()).c_str());
return false;
}
- std::unique_ptr<FILE, decltype(&fclose)> output(fopen(cur_name.c_str(), "w+"), &fclose);
+ std::unique_ptr<FILE, decltype(&fclose)> output(fopen(cur_name.c_str(), "we+"), &fclose);
if (output == nullptr) {
perror((std::string("Cannot create file " + cur_name)).c_str());
return false;
@@ -196,7 +196,7 @@ bool CreateElfFromMemory(pid_t tid, unwindstack::MapInfo* map_info, std::string*
return false;
}
- std::unique_ptr<FILE, decltype(&fclose)> output(fopen(cur_name.c_str(), "w+"), &fclose);
+ std::unique_ptr<FILE, decltype(&fclose)> output(fopen(cur_name.c_str(), "we+"), &fclose);
if (output == nullptr) {
perror((std::string("Cannot create ") + cur_name).c_str());
return false;
@@ -324,7 +324,7 @@ bool SaveData(pid_t tid, const std::filesystem::path& cwd, bool is_main_thread,
return false;
}
- std::unique_ptr<FILE, decltype(&fclose)> maps_fp(fopen("maps.txt", "w+"), &fclose);
+ std::unique_ptr<FILE, decltype(&fclose)> maps_fp(fopen("maps.txt", "we+"), &fclose);
if (maps_fp == nullptr) {
perror("Failed to create maps.txt");
return false;
@@ -372,7 +372,7 @@ int main(int argc, char** argv) {
fprintf(stderr, "Ensure there is no space between '-f' and the filename provided.\n");
return usage(EXIT_FAILURE);
}
- output_fp.reset(fopen(output_filename.c_str(), "a"));
+ output_fp.reset(fopen(output_filename.c_str(), "ae"));
break;
}
case '?': {