richardphibel / rpms / systemd

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