From 9818f95c9e6ec2e058ab4ae6ed0d1ffdd8eb94fe Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 1 Apr 2022 11:56:52 +0900 Subject: [PATCH] libprocessgroup: return false on failure SetProcessProfiles and SetTaskProfiles now correctly return false on failure. Bug: N/A Test: settaskprofile Change-Id: I7936303e71cd073c0ba713109328b960c66bdacc --- libprocessgroup/task_profiles.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libprocessgroup/task_profiles.cpp b/libprocessgroup/task_profiles.cpp index 27060aed5..e1c593407 100644 --- a/libprocessgroup/task_profiles.cpp +++ b/libprocessgroup/task_profiles.cpp @@ -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& 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"; + PLOG(WARNING) << "Failed to find " << name << " process profile"; + success = false; } } - return true; + return success; } bool TaskProfiles::SetTaskProfiles(int tid, const std::vector& 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& prof } if (!profile->ExecuteForTask(tid)) { PLOG(WARNING) << "Failed to apply " << name << " task profile"; + success = false; } } else { - PLOG(WARNING) << "Failed to find " << name << "task profile"; + PLOG(WARNING) << "Failed to find " << name << " task profile"; + success = false; } } - return true; + return success; }