bootloader_message: Remove global std::string
A global std::string, even if not used, pollutes the bss section unnecessarily. Since this object is only there for testing, make it std::optional<std::string>, which is constexpr constructible. Bug: 138856262 Test: Along with a fix in fs_mgr, see that the bss section for libbootloader_message.so is now clean on cuttlefish for several processes. Change-Id: I6df837dded88d979ffe14d5b2770b120bcf87341
This commit is contained in:
parent
c34e4e7fb5
commit
e94b64ae86
1 changed files with 4 additions and 3 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue