summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVic Yang <victoryang@google.com>2019-08-08 04:28:56 +0200
committerandroid-build-merger <android-build-merger@google.com>2019-08-08 04:28:56 +0200
commitc19d76833ace23f73cc3124a70a8a226862202ce (patch)
treef82328678920c272d2e46d6b245192f865b1c3dd
parentMerge "Simulator: add the argument to keep the updated images" am: c34e4e7fb5 am: be3f56543e am: 112acdc043 am: 05fa10519d (diff)
parentMerge "bootloader_message: Remove global std::string" am: 7b87949ae1 am: 76d80ba102 am: 8946524a79 (diff)
downloadandroid_bootable_recovery-c19d76833ace23f73cc3124a70a8a226862202ce.tar
android_bootable_recovery-c19d76833ace23f73cc3124a70a8a226862202ce.tar.gz
android_bootable_recovery-c19d76833ace23f73cc3124a70a8a226862202ce.tar.bz2
android_bootable_recovery-c19d76833ace23f73cc3124a70a8a226862202ce.tar.lz
android_bootable_recovery-c19d76833ace23f73cc3124a70a8a226862202ce.tar.xz
android_bootable_recovery-c19d76833ace23f73cc3124a70a8a226862202ce.tar.zst
android_bootable_recovery-c19d76833ace23f73cc3124a70a8a226862202ce.zip
-rw-r--r--bootloader_message/bootloader_message.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp
index e684abbad..b15a9b9fd 100644
--- a/bootloader_message/bootloader_message.cpp
+++ b/bootloader_message/bootloader_message.cpp
@@ -20,6 +20,7 @@
#include <fcntl.h>
#include <string.h>
+#include <optional>
#include <string>
#include <string_view>
#include <vector>
@@ -37,7 +38,7 @@
using android::fs_mgr::Fstab;
using android::fs_mgr::ReadDefaultFstab;
-static std::string g_misc_device_for_test;
+static std::optional<std::string> g_misc_device_for_test;
// Exposed for test purpose.
void SetMiscBlockDeviceForTest(std::string_view misc_device) {
@@ -45,8 +46,8 @@ void SetMiscBlockDeviceForTest(std::string_view misc_device) {
}
static std::string get_misc_blk_device(std::string* err) {
- if (!g_misc_device_for_test.empty()) {
- return g_misc_device_for_test;
+ if (g_misc_device_for_test.has_value() && !g_misc_device_for_test->empty()) {
+ return *g_misc_device_for_test;
}
Fstab fstab;
if (!ReadDefaultFstab(&fstab)) {