From: Michal Koutný Date: Tue, 29 Mar 2022 15:42:19 +0000 (+0200) Subject: core/cgroup: Refactor device weight property name X-Git-Tag: v251-rc2~168^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1cf4a685ad334d85dc5c0e61928577d76ca76311;p=thirdparty%2Fsystemd.git core/cgroup: Refactor device weight property name Use arithmetic over explicit list of existing property names. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 35edeac2adf..10081a0f9af 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -1064,6 +1064,12 @@ static uint64_t cgroup_weight_io_to_blkio(uint64_t io_weight) { } static void set_bfq_weight(Unit *u, const char *controller, dev_t dev, uint64_t io_weight) { + static const char * const prop_names[] = { + "IOWeight", + "BlockIOWeight", + "IODeviceWeight", + "BlockIODeviceWeight", + }; char buf[DECIMAL_STR_MAX(dev_t)*2+2+DECIMAL_STR_MAX(uint64_t)+STRLEN("\n")]; const char *p; uint64_t bfq_weight; @@ -1081,9 +1087,8 @@ static void set_bfq_weight(Unit *u, const char *controller, dev_t dev, uint64_t xsprintf(buf, "%" PRIu64 "\n", bfq_weight); if (set_attribute_and_warn(u, controller, p, buf) >= 0 && io_weight != bfq_weight) - log_unit_debug(u, "%sIO%sWeight=%" PRIu64 " scaled to %s=%" PRIu64, - streq(controller, "blkio") ? "Block" : "", - major(dev) > 0 ? "Device" : "", + log_unit_debug(u, "%s=%" PRIu64 " scaled to %s=%" PRIu64, + prop_names[2*(major(dev) > 0) + streq(controller, "blkio")], io_weight, p, bfq_weight); }