From 6856cfcb210ab2297e82c0077287c5a3a00d8df1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 24 Jan 2022 20:52:51 +0000 Subject: [PATCH] Use the 'override' keyword where appropriate This patch implements the following advice from the Google C++ Style Guide: "Explicitly annotate overrides of virtual functions or virtual destructors with exactly one of an override or (less frequently) final specifier. Do not use virtual when declaring an override. Rationale: A function or destructor marked override or final that is not an override of a base class virtual function will not compile, and this helps catch common errors. The specifiers serve as documentation; if no specifier is present, the reader has to check all ancestors of the class in question to determine if the function or destructor is virtual or not." Bug: 213617178 Test: Booted Android in Cuttlefish. Change-Id: Iabe7ecd91a2c09a77922c60ff4a00314da509d4a Signed-off-by: Bart Van Assche --- libprocessgroup/task_profiles.h | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libprocessgroup/task_profiles.h b/libprocessgroup/task_profiles.h index 2b2eda009..3cfa47c28 100644 --- a/libprocessgroup/task_profiles.h +++ b/libprocessgroup/task_profiles.h @@ -65,8 +65,8 @@ class SetClampsAction : public ProfileAction { public: SetClampsAction(int boost, int clamp) noexcept : boost_(boost), clamp_(clamp) {} - virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const; - virtual bool ExecuteForTask(int tid) const; + bool ExecuteForProcess(uid_t uid, pid_t pid) const override; + bool ExecuteForTask(int tid) const override; protected: int boost_; @@ -77,7 +77,7 @@ class SetTimerSlackAction : public ProfileAction { public: SetTimerSlackAction(unsigned long slack) noexcept : slack_(slack) {} - virtual bool ExecuteForTask(int tid) const; + bool ExecuteForTask(int tid) const override; private: unsigned long slack_; @@ -91,8 +91,8 @@ class SetAttributeAction : public ProfileAction { SetAttributeAction(const ProfileAttribute* attribute, const std::string& value) : attribute_(attribute), value_(value) {} - virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const; - virtual bool ExecuteForTask(int tid) const; + bool ExecuteForProcess(uid_t uid, pid_t pid) const override; + bool ExecuteForTask(int tid) const override; private: const ProfileAttribute* attribute_; @@ -104,10 +104,10 @@ class SetCgroupAction : public ProfileAction { public: SetCgroupAction(const CgroupController& c, const std::string& p); - virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const; - virtual bool ExecuteForTask(int tid) const; - virtual void EnableResourceCaching(ResourceCacheType cache_type); - virtual void DropResourceCaching(ResourceCacheType cache_type); + bool ExecuteForProcess(uid_t uid, pid_t pid) const override; + bool ExecuteForTask(int tid) const override; + void EnableResourceCaching(ResourceCacheType cache_type) override; + void DropResourceCaching(ResourceCacheType cache_type) override; const CgroupController* controller() const { return &controller_; } @@ -126,10 +126,10 @@ class WriteFileAction : public ProfileAction { public: WriteFileAction(const std::string& path, const std::string& value, bool logfailures); - virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const; - virtual bool ExecuteForTask(int tid) const; - virtual void EnableResourceCaching(ResourceCacheType cache_type); - virtual void DropResourceCaching(ResourceCacheType cache_type); + bool ExecuteForProcess(uid_t uid, pid_t pid) const override; + bool ExecuteForTask(int tid) const override; + void EnableResourceCaching(ResourceCacheType cache_type) override; + void DropResourceCaching(ResourceCacheType cache_type) override; private: std::string path_, value_; @@ -165,10 +165,10 @@ class ApplyProfileAction : public ProfileAction { ApplyProfileAction(const std::vector>& profiles) : profiles_(profiles) {} - virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const; - virtual bool ExecuteForTask(int tid) const; - virtual void EnableResourceCaching(ProfileAction::ResourceCacheType cache_type); - virtual void DropResourceCaching(ProfileAction::ResourceCacheType cache_type); + bool ExecuteForProcess(uid_t uid, pid_t pid) const override; + bool ExecuteForTask(int tid) const override; + void EnableResourceCaching(ProfileAction::ResourceCacheType cache_type) override; + void DropResourceCaching(ProfileAction::ResourceCacheType cache_type) override; private: std::vector> profiles_;