summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-11-05 18:15:46 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-11-05 21:06:08 +0100
commitb03fa16bd0342aa50aa897e71d050d05dddaa298 (patch)
treeaa4123f04cbc9cce8d28965c3cc4ecb30c4a57db
parentb7737f520276528bb96d32d83b6349d2eef1003a (diff)
downloadsystemd-b03fa16bd0342aa50aa897e71d050d05dddaa298.tar.gz
core/dbus-cgroup: use %.*s instead of strndupa()
-rw-r--r--src/core/dbus-cgroup.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index f0c8a70a66..4a9206076a 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -692,16 +692,14 @@ static int bus_cgroup_set_boolean(
"Value specified in %s is out of range", name); \
\
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
- const char *e; \
- \
*p = v; \
unit_invalidate_cgroup(u, mask); \
\
- /* Chop off suffix */ \
- assert_se(e = endswith(name, "Scale")); \
- name = strndupa(name, e - name); \
+ /* Prepare to chop off suffix */ \
+ assert_se(endswith(name, "Scale")); \
\
- unit_write_settingf(u, flags, name, "%s=%" PRIu32 "%%", name, \
+ unit_write_settingf(u, flags, name, "%.*s=%" PRIu32 "%%", \
+ (int)(strlen(name) - strlen("Scale")), name, \
(uint32_t) (DIV_ROUND_UP((uint64_t) raw * 100U, (uint64_t) UINT32_MAX))); \
} \
\