summaryrefslogtreecommitdiff
path: root/src/core/dbus-cgroup.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-02-17 17:03:52 +0100
committerLennart Poettering <lennart@poettering.net>2021-02-18 22:36:34 +0100
commit9cba32bcde31033bffbac6d53c028f8f95212293 (patch)
tree7e170ebf73467561f580e601b98ef76409363eed /src/core/dbus-cgroup.c
parent3b6e71ad0351c5ed2dd8382a63ab3581fa2d6174 (diff)
downloadsystemd-9cba32bcde31033bffbac6d53c028f8f95212293.tar.gz
tree-wide: port various pieces of code over to UINT32_SCALE_FROM_PERMYRIAD()
Diffstat (limited to 'src/core/dbus-cgroup.c')
-rw-r--r--src/core/dbus-cgroup.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 6652c212f1..e22233d6ff 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -16,6 +16,7 @@
#include "fileio.h"
#include "limits-util.h"
#include "path-util.h"
+#include "percent-util.h"
BUS_DEFINE_PROPERTY_GET(bus_property_get_tasks_max, "t", TasksMax, tasks_max_resolve);
@@ -704,10 +705,10 @@ static int bus_cgroup_set_boolean(
/* Prepare to chop off suffix */ \
assert_se(endswith(name, "Scale")); \
\
- uint32_t scaled = DIV_ROUND_UP((uint64_t) raw * 1000, (uint64_t) UINT32_MAX); \
- unit_write_settingf(u, flags, name, "%.*s=%" PRIu32 ".%" PRIu32 "%%", \
+ int scaled = UINT32_SCALE_TO_PERMYRIAD(raw); \
+ unit_write_settingf(u, flags, name, "%.*s=%i.%02i%%", \
(int)(strlen(name) - strlen("Scale")), name, \
- scaled / 10, scaled % 10); \
+ scaled / 100, scaled % 100); \
} \
\
return 1; \