diff options
author | Tao Bao <tbao@google.com> | 2015-06-03 10:49:29 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-07 19:02:26 -0800 |
commit | 0997ce973c09513e79a5b3e597cddf4e0ad77b62 (patch) | |
tree | 7385cfc99060b8cdde1e1093d548f2b1e2519baf /recovery.cpp | |
parent | f43603fbd68ffbbff81bc8653aa547a8acc7cc46 (diff) | |
download | bootable_recovery-0997ce973c09513e79a5b3e597cddf4e0ad77b62.zip bootable_recovery-0997ce973c09513e79a5b3e597cddf4e0ad77b62.tar.gz bootable_recovery-0997ce973c09513e79a5b3e597cddf4e0ad77b62.tar.bz2 |
recovery: Switch to clang
And a few trival fixes to suppress warnings.
Change-Id: I38734b5f4434643e85feab25f4807b46a45d8d65
Diffstat (limited to 'recovery.cpp')
-rw-r--r-- | recovery.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/recovery.cpp b/recovery.cpp index 5923c81..24533be 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; } |