libdm: Make static std::string inline for DmTargetDefaultKey.

Bug: 149942628
Test: snapshotctl w/ ASAN build
Change-Id: I0f40b1f29e46bc9afaf19d8c21d62280e2c01074
This commit is contained in:
David Anderson 2020-02-27 13:31:40 -08:00
parent 8ef1e1b535
commit 1a17e18f17
2 changed files with 4 additions and 5 deletions

View file

@ -243,12 +243,10 @@ std::string DmTargetCrypt::GetParameterString() const {
return android::base::Join(argv, " ");
}
const std::string DmTargetDefaultKey::name_ = "default-key";
bool DmTargetDefaultKey::IsLegacy(bool* result) {
DeviceMapper& dm = DeviceMapper::Instance();
DmTargetTypeInfo info;
if (!dm.GetTargetByName(name_, &info)) return false;
if (!dm.GetTargetByName(kName, &info)) return false;
// dm-default-key was modified to be like dm-crypt with version 2
*result = !info.IsAtLeast(2, 0, 0);
return true;

View file

@ -287,7 +287,7 @@ class DmTargetDefaultKey final : public DmTarget {
blockdev_(blockdev),
start_sector_(start_sector) {}
std::string name() const override { return name_; }
std::string name() const override { return kName; }
bool Valid() const override;
std::string GetParameterString() const override;
static bool IsLegacy(bool* result);
@ -296,7 +296,8 @@ class DmTargetDefaultKey final : public DmTarget {
void SetWrappedKeyV0() { is_hw_wrapped_ = true; }
private:
static const std::string name_;
inline static const std::string kName = "default-key";
std::string cipher_;
std::string key_;
std::string blockdev_;