diff --git a/libprocessgroup/cgroup_map.cpp b/libprocessgroup/cgroup_map.cpp index c8ae2161a..ebc059944 100644 --- a/libprocessgroup/cgroup_map.cpp +++ b/libprocessgroup/cgroup_map.cpp @@ -18,33 +18,19 @@ #define LOG_TAG "libprocessgroup" #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include #include -#include #include #include -#include #include -#include -#include #include -using android::base::GetBoolProperty; using android::base::StartsWith; using android::base::StringPrintf; -using android::base::unique_fd; using android::base::WriteStringToFile; static constexpr const char* CGROUP_PROCS_FILE = "/cgroup.procs"; diff --git a/libprocessgroup/cgroup_map.h b/libprocessgroup/cgroup_map.h index 5c6d3e21c..31925d5d7 100644 --- a/libprocessgroup/cgroup_map.h +++ b/libprocessgroup/cgroup_map.h @@ -16,14 +16,9 @@ #pragma once -#include #include -#include -#include -#include #include -#include #include @@ -32,7 +27,7 @@ class CgroupController { public: // Does not own controller explicit CgroupController(const ACgroupController* controller) - : controller_(controller), state_(UNKNOWN) {} + : controller_(controller) {} uint32_t version() const; const char* name() const; @@ -53,7 +48,7 @@ class CgroupController { }; const ACgroupController* controller_ = nullptr; - ControllerState state_; + ControllerState state_ = ControllerState::UNKNOWN; }; class CgroupMap { diff --git a/libprocessgroup/cgrouprc_format/cgroup_controller.cpp b/libprocessgroup/cgrouprc_format/cgroup_controller.cpp index 202b23eed..56e67df59 100644 --- a/libprocessgroup/cgrouprc_format/cgroup_controller.cpp +++ b/libprocessgroup/cgrouprc_format/cgroup_controller.cpp @@ -20,14 +20,9 @@ namespace android { namespace cgrouprc { namespace format { -CgroupController::CgroupController() : version_(0), flags_(0) { - memset(name_, 0, sizeof(name_)); - memset(path_, 0, sizeof(path_)); -} - CgroupController::CgroupController(uint32_t version, uint32_t flags, const std::string& name, const std::string& path) - : CgroupController() { +{ // strlcpy isn't available on host. Although there is an implementation // in licutils, libcutils itself depends on libcgrouprc_format, causing // a circular dependency. diff --git a/libprocessgroup/cgrouprc_format/include/processgroup/format/cgroup_controller.h b/libprocessgroup/cgrouprc_format/include/processgroup/format/cgroup_controller.h index 40d85480b..9427a1cf9 100644 --- a/libprocessgroup/cgrouprc_format/include/processgroup/format/cgroup_controller.h +++ b/libprocessgroup/cgrouprc_format/include/processgroup/format/cgroup_controller.h @@ -16,7 +16,8 @@ #pragma once -#include +#include +#include #include namespace android { @@ -26,7 +27,7 @@ namespace format { // Minimal controller description to be mmapped into process address space struct CgroupController { public: - CgroupController(); + CgroupController() = default; CgroupController(uint32_t version, uint32_t flags, const std::string& name, const std::string& path); @@ -41,10 +42,10 @@ struct CgroupController { static constexpr size_t CGROUP_NAME_BUF_SZ = 16; static constexpr size_t CGROUP_PATH_BUF_SZ = 32; - uint32_t version_; - uint32_t flags_; - char name_[CGROUP_NAME_BUF_SZ]; - char path_[CGROUP_PATH_BUF_SZ]; + uint32_t version_ = 0; + uint32_t flags_ = 0; + char name_[CGROUP_NAME_BUF_SZ] = {}; + char path_[CGROUP_PATH_BUF_SZ] = {}; }; } // namespace format diff --git a/libprocessgroup/cgrouprc_format/include/processgroup/format/cgroup_file.h b/libprocessgroup/cgrouprc_format/include/processgroup/format/cgroup_file.h index f1678a114..2d9786fe6 100644 --- a/libprocessgroup/cgrouprc_format/include/processgroup/format/cgroup_file.h +++ b/libprocessgroup/cgrouprc_format/include/processgroup/format/cgroup_file.h @@ -16,6 +16,8 @@ #pragma once +#include + #include namespace android { diff --git a/libprocessgroup/sched_policy.cpp b/libprocessgroup/sched_policy.cpp index 1005b1e3e..0f2640a0a 100644 --- a/libprocessgroup/sched_policy.cpp +++ b/libprocessgroup/sched_policy.cpp @@ -19,6 +19,7 @@ #define LOG_TAG "SchedPolicy" #include +#include #include #include diff --git a/libprocessgroup/setup/cgroup_descriptor.h b/libprocessgroup/setup/cgroup_descriptor.h index 699c03cec..9982bfc73 100644 --- a/libprocessgroup/setup/cgroup_descriptor.h +++ b/libprocessgroup/setup/cgroup_descriptor.h @@ -16,6 +16,11 @@ #pragma once +#include +#include + +#include + #include namespace android { diff --git a/libprocessgroup/task_profiles.cpp b/libprocessgroup/task_profiles.cpp index 0c2252b17..48705481c 100644 --- a/libprocessgroup/task_profiles.cpp +++ b/libprocessgroup/task_profiles.cpp @@ -17,7 +17,9 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "libprocessgroup" +#include #include +#include #include #include diff --git a/libprocessgroup/task_profiles.h b/libprocessgroup/task_profiles.h index 7e3c50d9f..184e9e35f 100644 --- a/libprocessgroup/task_profiles.h +++ b/libprocessgroup/task_profiles.h @@ -16,10 +16,10 @@ #pragma once -#include #include -#include + #include +#include #include #include #include