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

Commit 9949ec5f authored by Tom Cherry's avatar Tom Cherry
Browse files

init: replace Result<> with expected<>

Android-base has an implementation of the future std::expected<>.
This provides the same baseline functionality as Result<>, so use it
instead of our own version.

Bug: 132145659
Test: boot, init unit tests
Change-Id: I11e61bcb5719b262a6420483ed51a762826a9e23
parent 691e0e15
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ void Action::ExecuteCommand(const Command& command) const {
    // report such failures unless we're running at the DEBUG log level.
    bool report_failure = !result.has_value();
    if (report_failure && android::base::GetMinimumLogSeverity() > android::base::DEBUG &&
        result.error_errno() == ENOENT) {
        result.error().as_errno == ENOENT) {
        report_failure = false;
    }

@@ -139,7 +139,7 @@ void Action::ExecuteCommand(const Command& command) const {

        LOG(INFO) << "Command '" << cmd_str << "' action=" << trigger_name << " (" << filename_
                  << ":" << command.line() << ") took " << duration.count() << "ms and "
                  << (result ? "succeeded" : "failed: " + result.error_string());
                  << (result ? "succeeded" : "failed: " + result.error().as_string);
    }
}

+2 −2
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ Keychords::Keychords() : epoll_(nullptr), inotify_fd_(-1) {}

Keychords::~Keychords() noexcept {
    if (inotify_fd_ >= 0) {
        epoll_->UnregisterHandler(inotify_fd_).IgnoreError();
        epoll_->UnregisterHandler(inotify_fd_);
        ::close(inotify_fd_);
    }
    while (!registration_.empty()) GeteventCloseDevice(registration_.begin()->first);
@@ -212,7 +212,7 @@ void Keychords::GeteventCloseDevice(const std::string& device) {
    auto it = registration_.find(device);
    if (it == registration_.end()) return;
    auto fd = (*it).second;
    epoll_->UnregisterHandler(fd).IgnoreError();
    epoll_->UnregisterHandler(fd);
    registration_.erase(it);
    ::close(fd);
}
+1 −1
Original line number Diff line number Diff line
@@ -213,7 +213,7 @@ TestFrame::TestFrame(const std::vector<const std::vector<int>>& chords, EventHan
}

void TestFrame::RelaxForMs(std::chrono::milliseconds wait) {
    epoll_.Wait(wait).IgnoreError();
    epoll_.Wait(wait);
}

void TestFrame::SetChord(int key, bool value) {
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ MountHandler::MountHandler(Epoll* epoll) : epoll_(epoll), fp_(fopen("/proc/mount
}

MountHandler::~MountHandler() {
    if (fp_) epoll_->UnregisterHandler(fileno(fp_.get())).IgnoreError();
    if (fp_) epoll_->UnregisterHandler(fileno(fp_.get()));
}

void MountHandler::MountHandlerFunction() {
+2 −2
Original line number Diff line number Diff line
@@ -527,13 +527,13 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str

            // start all animation classes if stopped.
            if (do_shutdown_animation) {
                service->Start().IgnoreError();
                service->Start();
            }
            service->SetShutdownCritical();  // will not check animation class separately
        }

        if (do_shutdown_animation) {
            bootAnim->Start().IgnoreError();
            bootAnim->Start();
            surfaceFlinger->SetShutdownCritical();
            bootAnim->SetShutdownCritical();
        }
Loading