summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2019-08-08 03:24:29 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-08-08 03:24:29 +0200
commit7b87949ae148510e3c30a9879e6cb884228f8179 (patch)
treeeaa86f25080a33de712f5e6777dde0467d1a3629
parentMerge "Simulator: add the argument to keep the updated images" (diff)
parentbootloader_message: Remove global std::string (diff)
downloadandroid_bootable_recovery-7b87949ae148510e3c30a9879e6cb884228f8179.tar
android_bootable_recovery-7b87949ae148510e3c30a9879e6cb884228f8179.tar.gz
android_bootable_recovery-7b87949ae148510e3c30a9879e6cb884228f8179.tar.bz2
android_bootable_recovery-7b87949ae148510e3c30a9879e6cb884228f8179.tar.lz
android_bootable_recovery-7b87949ae148510e3c30a9879e6cb884228f8179.tar.xz
android_bootable_recovery-7b87949ae148510e3c30a9879e6cb884228f8179.tar.zst
android_bootable_recovery-7b87949ae148510e3c30a9879e6cb884228f8179.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)) {