From: Lennart Poettering Date: Thu, 15 Nov 2018 19:08:17 +0000 (+0100) Subject: cgtop: use FOREACH_STRING() for fun and profit X-Git-Tag: v240~303^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63a0cbbac3723c0684807fb39fc37f6c180d4a17;p=thirdparty%2Fsystemd.git cgtop: use FOREACH_STRING() for fun and profit --- diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index cf2de7eb5a8..efbfd240a6b 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -501,31 +501,14 @@ static int refresh_one( } static int refresh(const char *root, Hashmap *a, Hashmap *b, unsigned iteration) { + const char *c; int r; - assert(a); - - r = refresh_one(SYSTEMD_CGROUP_CONTROLLER, root, a, b, iteration, 0, NULL); - if (r < 0) - return r; - r = refresh_one("cpu", root, a, b, iteration, 0, NULL); - if (r < 0) - return r; - r = refresh_one("cpuacct", root, a, b, iteration, 0, NULL); - if (r < 0) - return r; - r = refresh_one("memory", root, a, b, iteration, 0, NULL); - if (r < 0) - return r; - r = refresh_one("io", root, a, b, iteration, 0, NULL); - if (r < 0) - return r; - r = refresh_one("blkio", root, a, b, iteration, 0, NULL); - if (r < 0) - return r; - r = refresh_one("pids", root, a, b, iteration, 0, NULL); - if (r < 0) - return r; + FOREACH_STRING(c, SYSTEMD_CGROUP_CONTROLLER, "cpu", "cpuacct", "memory", "io", "blkio", "pids") { + r = refresh_one(c, root, a, b, iteration, 0, NULL); + if (r < 0) + return r; + } return 0; }