summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-06-03 19:49:29 +0200
committerRom Lemarchand <romlem@google.com>2015-11-16 23:28:40 +0100
commit7101b2e2854985727b7ef65e5b5057e0ecf2d034 (patch)
tree937f286110e485837d6a50203c7ab362a4f7afdd /recovery.cpp
parentam 838768ca: am 15da523e: am 3c7f655b: (-s ours) am 0e804d54: am d396b9db: am 710b6bb9: am ec4b58ad: (-s ours) am ec63d564: Track usage of Vector / SortedVector from libutils DO NOT MERGE (diff)
downloadandroid_bootable_recovery-7101b2e2854985727b7ef65e5b5057e0ecf2d034.tar
android_bootable_recovery-7101b2e2854985727b7ef65e5b5057e0ecf2d034.tar.gz
android_bootable_recovery-7101b2e2854985727b7ef65e5b5057e0ecf2d034.tar.bz2
android_bootable_recovery-7101b2e2854985727b7ef65e5b5057e0ecf2d034.tar.lz
android_bootable_recovery-7101b2e2854985727b7ef65e5b5057e0ecf2d034.tar.xz
android_bootable_recovery-7101b2e2854985727b7ef65e5b5057e0ecf2d034.tar.zst
android_bootable_recovery-7101b2e2854985727b7ef65e5b5057e0ecf2d034.zip
Diffstat (limited to '')
-rw-r--r--recovery.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/recovery.cpp b/recovery.cpp
index b7a545898..a0c74524e 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -326,14 +326,18 @@ static void rotate_logs(int max) {
ensure_path_mounted(LAST_KMSG_FILE);
for (int i = max-1; i >= 0; --i) {
- std::string old_log = android::base::StringPrintf((i == 0) ? "%s" : "%s.%d",
- LAST_LOG_FILE, i);
+ std::string old_log = android::base::StringPrintf("%s", LAST_LOG_FILE);
+ if (i > 0) {
+ old_log += "." + std::to_string(i);
+ }
std::string new_log = android::base::StringPrintf("%s.%d", LAST_LOG_FILE, i+1);
// Ignore errors if old_log doesn't exist.
rename(old_log.c_str(), new_log.c_str());
- std::string old_kmsg = android::base::StringPrintf((i == 0) ? "%s" : "%s.%d",
- LAST_KMSG_FILE, i);
+ std::string old_kmsg = android::base::StringPrintf("%s", LAST_KMSG_FILE);
+ if (i > 0) {
+ old_kmsg += "." + std::to_string(i);
+ }
std::string new_kmsg = android::base::StringPrintf("%s.%d", LAST_KMSG_FILE, i+1);
rename(old_kmsg.c_str(), new_kmsg.c_str());
}
@@ -706,7 +710,10 @@ static void choose_recovery_file(Device* device) {
// Add LAST_KMSG_FILE + LAST_KMSG_FILE.x
for (int i = 0; i < KEEP_LOG_COUNT; i++) {
char* log_file;
- if (asprintf(&log_file, (i == 0) ? "%s" : "%s.%d", LAST_LOG_FILE, i) == -1) {
+ int ret;
+ ret = (i == 0) ? asprintf(&log_file, "%s", LAST_LOG_FILE) :
+ asprintf(&log_file, "%s.%d", LAST_LOG_FILE, i);
+ if (ret == -1) {
// memory allocation failure - return early. Should never happen.
return;
}
@@ -717,7 +724,9 @@ static void choose_recovery_file(Device* device) {
}
char* kmsg_file;
- if (asprintf(&kmsg_file, (i == 0) ? "%s" : "%s.%d", LAST_KMSG_FILE, i) == -1) {
+ ret = (i == 0) ? asprintf(&kmsg_file, "%s", LAST_KMSG_FILE) :
+ asprintf(&kmsg_file, "%s.%d", LAST_KMSG_FILE, i);
+ if (ret == -1) {
// memory allocation failure - return early. Should never happen.
return;
}