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

Commit 4c67290d authored by Tom Cherry's avatar Tom Cherry Committed by Gerrit Code Review
Browse files

Merge "init: add [[nodiscard]] to Result"

parents a2ccce87 d9872646
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1018,7 +1018,11 @@ static Result<Success> ExecWithRebootOnFailure(const std::string& reboot_reason,
        if (siginfo.si_code != CLD_EXITED || siginfo.si_status != 0) {
            if (e4crypt_is_native()) {
                LOG(ERROR) << "Rebooting into recovery, reason: " << reboot_reason;
                reboot_into_recovery({"--prompt_and_wipe_data", "--reason="s + reboot_reason});
                if (auto result = reboot_into_recovery(
                            {"--prompt_and_wipe_data", "--reason="s + reboot_reason});
                    !result) {
                    LOG(FATAL) << "Could not reboot into recovery: " << result.error();
                }
            } else {
                LOG(ERROR) << "Failure (reboot suppressed): " << reboot_reason;
            }
+12 −4
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_);
        epoll_->UnregisterHandler(inotify_fd_).IgnoreError();
        ::close(inotify_fd_);
    }
    while (!registration_.empty()) GeteventCloseDevice(registration_.begin()->first);
@@ -186,7 +186,11 @@ bool Keychords::GeteventEnable(int fd) {
        current_ |= mask & available & set;
        LambdaCheck();
    }
    epoll_->RegisterHandler(fd, [this, fd]() { this->LambdaHandler(fd); });
    if (auto result = epoll_->RegisterHandler(fd, [this, fd]() { this->LambdaHandler(fd); });
        !result) {
        LOG(WARNING) << "Could not register keychord epoll handler: " << result.error();
        return false;
    }
    return true;
}

@@ -208,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);
    epoll_->UnregisterHandler(fd).IgnoreError();
    registration_.erase(it);
    ::close(fd);
}
@@ -266,7 +270,11 @@ void Keychords::GeteventOpenDevice() {
    }

    if (inotify_fd_ >= 0) {
        if (auto result =
                    epoll_->RegisterHandler(inotify_fd_, [this]() { this->InotifyHandler(); });
            !result) {
            LOG(WARNING) << "Could not register keychord epoll handler: " << result.error();
        }
    }
}

+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);
    epoll_.Wait(wait).IgnoreError();
}

void TestFrame::SetChord(int key, bool value) {
+3 −1
Original line number Diff line number Diff line
@@ -142,7 +142,9 @@ static void TurnOffBacklight() {
        LOG(WARNING) << "cannot find blank_screen in TurnOffBacklight";
        return;
    }
    service->Start();
    if (auto result = service->Start(); !result) {
        LOG(WARNING) << "Could not start blank_screen service: " << result.error();
    }
}

static void ShutdownVold() {
+3 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ inline Error ErrnoError() {
}

template <typename T>
class Result {
class [[nodiscard]] Result {
  public:
    Result() {}

@@ -170,6 +170,8 @@ class Result {
        : contents_(std::in_place_index_t<1>(), std::move(result_error.error_string),
                    result_error.error_errno) {}

    void IgnoreError() const {}

    bool has_value() const { return contents_.index() == 0; }

    T& value() & { return std::get<0>(contents_); }
Loading