cgroup: append \n to static strings we write to cgroup attributes
authorLennart Poettering <lennart@poettering.net>
Tue, 20 Nov 2018 21:50:13 +0000 (22:50 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Nov 2018 11:24:37 +0000 (12:24 +0100)
This is a bit cleaner since we when we format numeric limits we append
it. And this way write_string_file() doesn't have to append it.

src/core/cgroup.c

index bc676fc..e7b1b2b 100644 (file)
@@ -609,7 +609,7 @@ static void cgroup_apply_legacy_cpu_config(Unit *u, uint64_t shares, uint64_t qu
                 xsprintf(buf, USEC_FMT "\n", quota * CGROUP_CPU_QUOTA_PERIOD_USEC / USEC_PER_SEC);
                 (void) set_attribute_and_warn(u, "cpu", "cpu.cfs_quota_us", buf);
         } else
-                (void) set_attribute_and_warn(u, "cpu", "cpu.cfs_quota_us", "-1");
+                (void) set_attribute_and_warn(u, "cpu", "cpu.cfs_quota_us", "-1\n");
 }
 
 static uint64_t cgroup_cpu_shares_to_weight(uint64_t shares) {
@@ -756,7 +756,7 @@ static bool cgroup_context_has_unified_memory_config(CGroupContext *c) {
 }
 
 static void cgroup_apply_unified_memory_limit(Unit *u, const char *file, uint64_t v) {
-        char buf[DECIMAL_STR_MAX(uint64_t) + 1] = "max";
+        char buf[DECIMAL_STR_MAX(uint64_t) + 1] = "max\n";
 
         if (v != CGROUP_LIMIT_MAX)
                 xsprintf(buf, "%" PRIu64 "\n", v);
@@ -1136,7 +1136,7 @@ static void cgroup_context_apply(
                                 sprintf(buf, "%" PRIu64 "\n", c->tasks_max);
                                 (void) set_attribute_and_warn(u, "pids", "pids.max", buf);
                         } else
-                                (void) set_attribute_and_warn(u, "pids", "pids.max", "max");
+                                (void) set_attribute_and_warn(u, "pids", "pids.max", "max\n");
                 }
         }