|
|
4cad4c |
From f7b462bacb3c0ed1f7bbe63193e9e349aafd21d3 Mon Sep 17 00:00:00 2001
|
|
|
4cad4c |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
4cad4c |
Date: Tue, 20 Nov 2018 19:45:02 +0100
|
|
|
4cad4c |
Subject: [PATCH] cgroup: use structured initialization
|
|
|
4cad4c |
|
|
|
4cad4c |
(cherry picked from commit de8a711a5849f9239c93aefa5554a62986dfce42)
|
|
|
4cad4c |
|
|
|
4cad4c |
Related: #1770379
|
|
|
4cad4c |
---
|
|
|
4cad4c |
src/core/cgroup.c | 33 +++++++++++++++++----------------
|
|
|
4cad4c |
1 file changed, 17 insertions(+), 16 deletions(-)
|
|
|
4cad4c |
|
|
|
4cad4c |
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
|
|
|
4cad4c |
index ad8219bd79..7aa7db9261 100644
|
|
|
4cad4c |
--- a/src/core/cgroup.c
|
|
|
4cad4c |
+++ b/src/core/cgroup.c
|
|
|
4cad4c |
@@ -71,29 +71,30 @@ static void cgroup_compat_warn(void) {
|
|
|
4cad4c |
void cgroup_context_init(CGroupContext *c) {
|
|
|
4cad4c |
assert(c);
|
|
|
4cad4c |
|
|
|
4cad4c |
- /* Initialize everything to the kernel defaults, assuming the
|
|
|
4cad4c |
- * structure is preinitialized to 0 */
|
|
|
4cad4c |
+ /* Initialize everything to the kernel defaults. */
|
|
|
4cad4c |
|
|
|
4cad4c |
- c->cpu_weight = CGROUP_WEIGHT_INVALID;
|
|
|
4cad4c |
- c->startup_cpu_weight = CGROUP_WEIGHT_INVALID;
|
|
|
4cad4c |
- c->cpu_quota_per_sec_usec = USEC_INFINITY;
|
|
|
4cad4c |
+ *c = (CGroupContext) {
|
|
|
4cad4c |
+ .cpu_weight = CGROUP_WEIGHT_INVALID,
|
|
|
4cad4c |
+ .startup_cpu_weight = CGROUP_WEIGHT_INVALID,
|
|
|
4cad4c |
+ .cpu_quota_per_sec_usec = USEC_INFINITY,
|
|
|
4cad4c |
|
|
|
4cad4c |
- c->cpu_shares = CGROUP_CPU_SHARES_INVALID;
|
|
|
4cad4c |
- c->startup_cpu_shares = CGROUP_CPU_SHARES_INVALID;
|
|
|
4cad4c |
+ .cpu_shares = CGROUP_CPU_SHARES_INVALID,
|
|
|
4cad4c |
+ .startup_cpu_shares = CGROUP_CPU_SHARES_INVALID,
|
|
|
4cad4c |
|
|
|
4cad4c |
- c->memory_high = CGROUP_LIMIT_MAX;
|
|
|
4cad4c |
- c->memory_max = CGROUP_LIMIT_MAX;
|
|
|
4cad4c |
- c->memory_swap_max = CGROUP_LIMIT_MAX;
|
|
|
4cad4c |
+ .memory_high = CGROUP_LIMIT_MAX,
|
|
|
4cad4c |
+ .memory_max = CGROUP_LIMIT_MAX,
|
|
|
4cad4c |
+ .memory_swap_max = CGROUP_LIMIT_MAX,
|
|
|
4cad4c |
|
|
|
4cad4c |
- c->memory_limit = CGROUP_LIMIT_MAX;
|
|
|
4cad4c |
+ .memory_limit = CGROUP_LIMIT_MAX,
|
|
|
4cad4c |
|
|
|
4cad4c |
- c->io_weight = CGROUP_WEIGHT_INVALID;
|
|
|
4cad4c |
- c->startup_io_weight = CGROUP_WEIGHT_INVALID;
|
|
|
4cad4c |
+ .io_weight = CGROUP_WEIGHT_INVALID,
|
|
|
4cad4c |
+ .startup_io_weight = CGROUP_WEIGHT_INVALID,
|
|
|
4cad4c |
|
|
|
4cad4c |
- c->blockio_weight = CGROUP_BLKIO_WEIGHT_INVALID;
|
|
|
4cad4c |
- c->startup_blockio_weight = CGROUP_BLKIO_WEIGHT_INVALID;
|
|
|
4cad4c |
+ .blockio_weight = CGROUP_BLKIO_WEIGHT_INVALID,
|
|
|
4cad4c |
+ .startup_blockio_weight = CGROUP_BLKIO_WEIGHT_INVALID,
|
|
|
4cad4c |
|
|
|
4cad4c |
- c->tasks_max = (uint64_t) -1;
|
|
|
4cad4c |
+ .tasks_max = CGROUP_LIMIT_MAX,
|
|
|
4cad4c |
+ };
|
|
|
4cad4c |
}
|
|
|
4cad4c |
|
|
|
4cad4c |
void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a) {
|