From: Zbigniew Jędrzejewski-Szmek Date: Wed, 30 Jun 2021 15:10:43 +0000 (+0200) Subject: core/cgroup: inline more iterator variable declarations X-Git-Tag: v249-rc3~16^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8616626eb0e48831d190e9ac2b0c4a72382ac30;p=thirdparty%2Fsystemd.git core/cgroup: inline more iterator variable declarations --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 3cec8a57863..21b2055ca5d 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -517,9 +517,8 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { LIST_FOREACH(device_limits, il, c->io_device_limits) { char buf[FORMAT_BYTES_MAX]; - CGroupIOLimitType type; - for (type = 0; type < _CGROUP_IO_LIMIT_TYPE_MAX; type++) + for (CGroupIOLimitType type = 0; type < _CGROUP_IO_LIMIT_TYPE_MAX; type++) if (il->limits[type] != cgroup_io_limit_defaults[type]) fprintf(f, "%s%s: %s %s\n", @@ -1347,9 +1346,8 @@ static void cgroup_context_apply( LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths) { uint64_t limits[_CGROUP_IO_LIMIT_TYPE_MAX]; - CGroupIOLimitType type; - for (type = 0; type < _CGROUP_IO_LIMIT_TYPE_MAX; type++) + for (CGroupIOLimitType type = 0; type < _CGROUP_IO_LIMIT_TYPE_MAX; type++) limits[type] = cgroup_io_limit_defaults[type]; limits[CGROUP_IO_RBPS_MAX] = b->rbps; @@ -1534,7 +1532,6 @@ static void cgroup_context_apply( static bool unit_get_needs_bpf_firewall(Unit *u) { CGroupContext *c; - Unit *p; assert(u); c = unit_get_cgroup_context(u); @@ -1549,7 +1546,7 @@ static bool unit_get_needs_bpf_firewall(Unit *u) { return true; /* If any parent slice has an IP access list defined, it applies too */ - for (p = UNIT_GET_SLICE(u); p; p = UNIT_GET_SLICE(p)) { + for (Unit *p = UNIT_GET_SLICE(u); p; p = UNIT_GET_SLICE(p)) { c = unit_get_cgroup_context(p); if (!c) return false; @@ -2163,7 +2160,6 @@ int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) { r = 0; SET_FOREACH(pidp, pids) { pid_t pid = PTR_TO_PID(pidp); - CGroupController c; /* First, attach the PID to the main cgroup hierarchy */ q = cg_attach(SYSTEMD_CGROUP_CONTROLLER, p, pid); @@ -2200,7 +2196,7 @@ int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) { /* In the legacy hierarchy, attach the process to the request cgroup if possible, and if not to the * innermost realized one */ - for (c = 0; c < _CGROUP_CONTROLLER_MAX; c++) { + for (CGroupController c = 0; c < _CGROUP_CONTROLLER_MAX; c++) { CGroupMask bit = CGROUP_CONTROLLER_TO_MASK(c); const char *realized; @@ -3137,7 +3133,6 @@ static int cg_bpf_mask_supported(CGroupMask *ret) { int manager_setup_cgroup(Manager *m) { _cleanup_free_ char *path = NULL; const char *scope_path; - CGroupController c; int r, all_unified; CGroupMask mask; char *e; @@ -3285,8 +3280,9 @@ int manager_setup_cgroup(Manager *m) { m->cgroup_supported |= mask; /* 10. Log which controllers are supported */ - for (c = 0; c < _CGROUP_CONTROLLER_MAX; c++) - log_debug("Controller '%s' supported: %s", cgroup_controller_to_string(c), yes_no(m->cgroup_supported & CGROUP_CONTROLLER_TO_MASK(c))); + for (CGroupController c = 0; c < _CGROUP_CONTROLLER_MAX; c++) + log_debug("Controller '%s' supported: %s", cgroup_controller_to_string(c), + yes_no(m->cgroup_supported & CGROUP_CONTROLLER_TO_MASK(c))); return 0; }