]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/cgroup: Refactor device weight property name
authorMichal Koutný <mkoutny@suse.com>
Tue, 29 Mar 2022 15:42:19 +0000 (17:42 +0200)
committerMichal Koutný <mkoutny@suse.com>
Tue, 29 Mar 2022 15:46:11 +0000 (17:46 +0200)
Use arithmetic over explicit list of existing property names.

src/core/cgroup.c

index 35edeac2adf2db09c9ebf58b8840dca843dec9b4..10081a0f9af8d6da7aaf49e0e66f38834e72c293 100644 (file)
@@ -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);
 }