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

Commit 9818f95c authored by Jiyong Park's avatar Jiyong Park
Browse files

libprocessgroup: return false on failure

SetProcessProfiles and SetTaskProfiles now correctly return false on
failure.

Bug: N/A
Test: settaskprofile <some_pid> <non_existing_name>

Change-Id: I7936303e71cd073c0ba713109328b960c66bdacc
parent b5a5095b
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -806,6 +806,7 @@ const IProfileAttribute* TaskProfiles::GetAttribute(const std::string& name) con

bool TaskProfiles::SetProcessProfiles(uid_t uid, pid_t pid,
                                      const std::vector<std::string>& profiles, bool use_fd_cache) {
    bool success = true;
    for (const auto& name : profiles) {
        TaskProfile* profile = GetProfile(name);
        if (profile != nullptr) {
@@ -814,16 +815,19 @@ bool TaskProfiles::SetProcessProfiles(uid_t uid, pid_t pid,
            }
            if (!profile->ExecuteForProcess(uid, pid)) {
                PLOG(WARNING) << "Failed to apply " << name << " process profile";
                success = false;
            }
        } else {
            PLOG(WARNING) << "Failed to find " << name << " process profile";
            success = false;
        }
    }
    return true;
    return success;
}

bool TaskProfiles::SetTaskProfiles(int tid, const std::vector<std::string>& profiles,
                                   bool use_fd_cache) {
    bool success = true;
    for (const auto& name : profiles) {
        TaskProfile* profile = GetProfile(name);
        if (profile != nullptr) {
@@ -832,10 +836,12 @@ bool TaskProfiles::SetTaskProfiles(int tid, const std::vector<std::string>& prof
            }
            if (!profile->ExecuteForTask(tid)) {
                PLOG(WARNING) << "Failed to apply " << name << " task profile";
                success = false;
            }
        } else {
            PLOG(WARNING) << "Failed to find " << name << " task profile";
            success = false;
        }
    }
    return true;
    return success;
}