richardphibel / rpms / systemd

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