Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 743e8f16 authored by Douglas Anderson's avatar Douglas Anderson
Browse files

init: Use ConsumePrefix() instead of open coding in GetBlockDeviceSymlinks()

In GetBlockDeviceSymlinks() we may need to strip the
"/devices/platform/" or "/devices/" from a string. Use the helper
ConsumePrefix() to do this, which is more convenient and readable.

This change is intended to be a no-op and just a cleanup.

Bug: 316324155
Test: Build and boot
Change-Id: I1adb1906ec37ff8f6f505abc5f26e1e3b157e608
parent 5d5906fb
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
using namespace std::chrono_literals;

using android::base::Basename;
using android::base::ConsumePrefix;
using android::base::Dirname;
using android::base::ReadFileToString;
using android::base::Readlink;
@@ -386,11 +387,10 @@ std::vector<std::string> DeviceHandler::GetBlockDeviceSymlinks(const Uevent& uev
        // Skip /devices/platform or /devices/ if present
        static constexpr std::string_view devices_platform_prefix = "/devices/platform/";
        static constexpr std::string_view devices_prefix = "/devices/";
        std::string_view str = device;

        if (StartsWith(device, devices_platform_prefix)) {
            device = device.substr(devices_platform_prefix.length());
        } else if (StartsWith(device, devices_prefix)) {
            device = device.substr(devices_prefix.length());
        if (ConsumePrefix(&str, devices_platform_prefix) || ConsumePrefix(&str, devices_prefix)) {
            device = str;
        }

        type = "platform";