]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools: match naming with upstream Linux
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Sat, 12 Oct 2024 01:06:50 +0000 (06:36 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 22 Oct 2024 15:53:24 +0000 (09:53 -0600)
Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
across the files under src/tools/ bringing it closer to the Linux kernel
cgroup code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/tools/cgclassify.c
src/tools/cgconfig.c
src/tools/cgcreate.c
src/tools/cgdelete.c
src/tools/cgexec.c
src/tools/cgget.c
src/tools/cgset.c
src/tools/cgsnapshot.c
src/tools/cgxget.c
src/tools/cgxset.c
src/tools/lscgroup.c

index ad3e530bdd703843f6b13b7a93e9a47879a9f7c1..368e01e52f525f3e4332459fdfe592f62b39722e 100644 (file)
@@ -68,17 +68,17 @@ static void usage(int status, const char *program_name)
 /*
  * Change process group as specified on command line.
  */
-static int change_group_path(pid_t pid, struct cgroup_group_spec *cgroup_list[])
+static int change_group_path(pid_t pid, struct cgroup_group_spec *cgrp_list[])
 {
        int ret = 0;
        int i;
 
        for (i = 0; i < CG_HIER_MAX; i++) {
-               if (!cgroup_list[i])
+               if (!cgrp_list[i])
                        break;
 
-               ret = cgroup_change_cgroup_path(cgroup_list[i]->path, pid,
-                                               (const char *const*) cgroup_list[i]->controllers);
+               ret = cgroup_change_cgroup_path(cgrp_list[i]->path, pid,
+                                               (const char *const*) cgrp_list[i]->controllers);
                if (ret) {
                        err("Error changing group of pid %d: %s\n", pid, cgroup_strerror(ret));
                        return -1;
@@ -134,15 +134,15 @@ static struct option longopts[] = {
 
 int main(int argc, char *argv[])
 {
-       struct cgroup_group_spec *cgroup_list[CG_HIER_MAX];
+       struct cgroup_group_spec *cgrp_list[CG_HIER_MAX];
 #ifdef WITH_SYSTEMD
        int ignore_default_systemd_delegate_slice = 0;
 #endif
        int ret = 0, i, exit_code = 0;
        int skip_replace_idle = 0;
+       int cgrp_specified = 0;
        pid_t scope_pid = -1;
        int replace_idle = 0;
-       int cg_specified = 0;
        int flag = 0;
        char *endptr;
        pid_t pid;
@@ -153,7 +153,7 @@ int main(int argc, char *argv[])
                exit(EXIT_BADARGS);
        }
 
-       memset(cgroup_list, 0, sizeof(cgroup_list));
+       memset(cgrp_list, 0, sizeof(cgrp_list));
 #ifdef WITH_SYSTEMD
        while ((c = getopt_long(argc, argv, "+g:shbr", longopts, NULL)) > 0) {
                switch (c) {
@@ -172,12 +172,12 @@ int main(int argc, char *argv[])
                        exit(0);
                        break;
                case 'g':
-                       ret = parse_cgroup_spec(cgroup_list, optarg, CG_HIER_MAX);
+                       ret = parse_cgroup_spec(cgrp_list, optarg, CG_HIER_MAX);
                        if (ret) {
                                err("cgroup controller and path parsing failed\n");
                                exit(EXIT_BADARGS);
                        }
-                       cg_specified = 1;
+                       cgrp_specified = 1;
                        break;
                case 's':
                        flag |= CGROUP_DAEMON_UNCHANGE_CHILDREN;
@@ -226,8 +226,8 @@ int main(int argc, char *argv[])
                        }
                }
 
-               if (cg_specified)
-                       ret = change_group_path(pid, cgroup_list);
+               if (cgrp_specified)
+                       ret = change_group_path(pid, cgrp_list);
                else
                        ret = change_group_based_on_rule(pid);
 
@@ -296,8 +296,8 @@ static pid_t find_scope_pid(pid_t pid, int capture)
 {
        pid_t _scope_pid = -1, scope_pid = -1;
        char ctrl_name[CONTROL_NAMELEN_MAX];
-       char cgroup_name[FILENAME_MAX];
        char scope_name[FILENAME_MAX];
+       char cgrp_name[FILENAME_MAX];
        int found_systemd_cgrp = 0;
        int found_unified_cgrp = 0;
        char buffer[FILENAME_MAX];
@@ -331,9 +331,9 @@ static pid_t find_scope_pid(pid_t pid, int capture)
                /* read according to the cgroup mode */
                if (strstr(buffer, "::")) {
                        snprintf(ctrl_name, CONTROL_NAMELEN_MAX, "unified");
-                       ret = sscanf(buffer, "%d::%4096s\n", &idx, cgroup_name);
+                       ret = sscanf(buffer, "%d::%4096s\n", &idx, cgrp_name);
                } else {
-                       ret = sscanf(buffer, "%d:%[^:]:%4096s\n", &idx, ctrl_name, cgroup_name);
+                       ret = sscanf(buffer, "%d:%[^:]:%4096s\n", &idx, ctrl_name, cgrp_name);
                }
 
                if (ret != 2 && ret != 3) {
@@ -355,7 +355,7 @@ static pid_t find_scope_pid(pid_t pid, int capture)
                 */
                if (capture) {
                        snprintf(info[i].ctrl_name, CONTROL_NAMELEN_MAX, "%s", ctrl_name);
-                       snprintf(info[i].cgrp_path, FILENAME_MAX, "%s", cgroup_name);
+                       snprintf(info[i].cgrp_path, FILENAME_MAX, "%s", cgrp_name);
                }
 
                if (!is_cgroup_mode_unified()) {
@@ -378,21 +378,21 @@ static pid_t find_scope_pid(pid_t pid, int capture)
                        continue;
 
                /* skip if the cgroup path doesn't have systemd scope format */
-               if (strstr(cgroup_name, ".scope") == NULL ||
-                   strstr(cgroup_name, ".slice") == NULL)
+               if (strstr(cgrp_name, ".scope") == NULL ||
+                   strstr(cgrp_name, ".slice") == NULL)
                        continue;
 
                /* skip if we have already searched cgroup for idle_thread */
-               if (is_scope_parsed(cgroup_name))
+               if (is_scope_parsed(cgrp_name))
                        continue;
 
 
                if (ret == 2)
-                       ret = cgroup_get_procs(cgroup_name, NULL, &pids, &size);
+                       ret = cgroup_get_procs(cgrp_name, NULL, &pids, &size);
                else
-                       ret = cgroup_get_procs(cgroup_name, ctrl_name, &pids, &size);
+                       ret = cgroup_get_procs(cgrp_name, ctrl_name, &pids, &size);
                if (ret) {
-                       err("Failed to read cgroup.procs of cgroup: %s\n", cgroup_name + 1);
+                       err("Failed to read cgroup.procs of cgroup: %s\n", cgrp_name + 1);
                        scope_pid = -1;
                        goto out;
                }
@@ -413,7 +413,7 @@ static pid_t find_scope_pid(pid_t pid, int capture)
                         * ../systemd/<slice>/<scope>/cgroup.procs (legacy/hybrid)
                         * ../unified/<slice>/<scope>/cgroup.procs (hybrid)
                         */
-                       snprintf(scope_name, FILENAME_MAX, "%s", cgroup_name);
+                       snprintf(scope_name, FILENAME_MAX, "%s", cgrp_name);
                        scope_pid = _scope_pid;
                        continue;
                }
@@ -471,7 +471,7 @@ out:
 static void find_mnt_point(const char * const controller, char **mnt_point)
 {
        char proc_mount[] = "/proc/mounts";
-       char cgroup_path[FILENAME_MAX];
+       char cgrp_path[FILENAME_MAX];
        char buffer[FILENAME_MAX * 2];
        FILE *proc_mount_f = NULL;
        int ret;
@@ -490,20 +490,19 @@ static void find_mnt_point(const char * const controller, char **mnt_point)
                        continue;
 
                if (strcmp(controller, "name=systemd") == 0) {
-                       if (!strstr(buffer, "name=systemd ") &&
-                           !strstr(buffer, "name=systemd,"))
+                       if (!strstr(buffer, "name=systemd ") && !strstr(buffer, "name=systemd,"))
                                continue;
                }
 
-               ret = sscanf(buffer, "%*s %4096s\n", cgroup_path);
+               ret = sscanf(buffer, "%*s %4096s\n", cgrp_path);
                if (ret != 1) {
                        err("Failed during read of %s:%s\n", proc_mount, strerror(errno));
                        goto out;
                }
 
-               *mnt_point = strdup(cgroup_path);
+               *mnt_point = strdup(cgrp_path);
                if (!*mnt_point)
-                       err("strdup of %s failed\n", cgroup_path);
+                       err("strdup of %s failed\n", cgrp_path);
                break;
        }
 
@@ -514,25 +513,25 @@ out:
 
 static int write_systemd_unified(const char * const scope_name, pid_t pid)
 {
-       char cgroup_procs_path[FILENAME_MAX + 14];
-       FILE *cgroup_systemd_path_f = NULL;
-       FILE *cgroup_unified_path_f = NULL;
-       char *cgroup_name = NULL;
+       char cgrp_procs_path[FILENAME_MAX + 14];
+       FILE *cgrp_systemd_path_f = NULL;
+       FILE *cgrp_unified_path_f = NULL;
+       char *cgrp_name = NULL;
 
        /* construct the systemd cgroup path, by parsing /proc/mounts */
-       find_mnt_point("name=systemd", &cgroup_name);
-       if (!cgroup_name) {
+       find_mnt_point("name=systemd", &cgrp_name);
+       if (!cgrp_name) {
                err("Unable find name=systemd cgroup path\n");
                return -1;
        }
 
-       snprintf(cgroup_procs_path, sizeof(cgroup_procs_path), "%s/%s/cgroup.procs",
-                cgroup_name, scope_name);
-       free(cgroup_name);
+       snprintf(cgrp_procs_path, sizeof(cgrp_procs_path), "%s/%s/cgroup.procs",
+                cgrp_name, scope_name);
+       free(cgrp_name);
 
-       cgroup_systemd_path_f = fopen(cgroup_procs_path, "we");
-       if (!cgroup_systemd_path_f) {
-               err("Failed to open %s\n", cgroup_procs_path);
+       cgrp_systemd_path_f = fopen(cgrp_procs_path, "we");
+       if (!cgrp_systemd_path_f) {
+               err("Failed to open %s\n", cgrp_procs_path);
                return -1;
        }
 
@@ -541,35 +540,35 @@ static int write_systemd_unified(const char * const scope_name, pid_t pid)
                 * construct the unified cgroup path, by parsing
                 * /proc/mounts
                 */
-               find_mnt_point("unified", &cgroup_name);
-               if (!cgroup_name) {
+               find_mnt_point("unified", &cgrp_name);
+               if (!cgrp_name) {
                        err("Unable find unified cgroup path\n");
-                       fclose(cgroup_systemd_path_f);
+                       fclose(cgrp_systemd_path_f);
                        return -1;
                }
 
-               snprintf(cgroup_procs_path, sizeof(cgroup_procs_path), "%s/%s/cgroup.procs",
-                        cgroup_name, scope_name);
-               free(cgroup_name);
+               snprintf(cgrp_procs_path, sizeof(cgrp_procs_path), "%s/%s/cgroup.procs",
+                        cgrp_name, scope_name);
+               free(cgrp_name);
 
-               cgroup_unified_path_f = fopen(cgroup_procs_path, "we");
-               if (!cgroup_unified_path_f) {
-                       err("Failed to open %s\n", cgroup_procs_path);
-                       fclose(cgroup_systemd_path_f);
+               cgrp_unified_path_f = fopen(cgrp_procs_path, "we");
+               if (!cgrp_unified_path_f) {
+                       err("Failed to open %s\n", cgrp_procs_path);
+                       fclose(cgrp_systemd_path_f);
                        return -1;
                }
        }
 
-       fprintf(cgroup_systemd_path_f, "%d", pid);
-       fflush(cgroup_systemd_path_f);
-       fclose(cgroup_systemd_path_f);
+       fprintf(cgrp_systemd_path_f, "%d", pid);
+       fflush(cgrp_systemd_path_f);
+       fclose(cgrp_systemd_path_f);
 
        if (!is_cgroup_mode_hybrid())
                return 0;
 
-       fprintf(cgroup_unified_path_f, "%d", pid);
-       fflush(cgroup_unified_path_f);
-       fclose(cgroup_unified_path_f);
+       fprintf(cgrp_unified_path_f, "%d", pid);
+       fflush(cgrp_unified_path_f);
+       fclose(cgrp_unified_path_f);
 
        return 0;
 }
@@ -638,10 +637,11 @@ err:
 
 static int rollback_pid_cgroups(pid_t pid)
 {
-       char cgroup_proc_path[FILENAME_MAX + 14];
-       char cgroup_path[FILENAME_MAX];
-       int err = 0, idx = 0, ret = 0;
-       char *cgrp_proc_path = NULL;
+       char cgrp_proc_path[FILENAME_MAX + 14];
+       char cgrp_path[FILENAME_MAX];
+       char *_cgrp_proc_path = NULL;
+       int err = 0, idx = 0;
+       int ret = 0;
 
        /*
         * unified cgroup rollback is simple, we need to write into
@@ -649,52 +649,51 @@ static int rollback_pid_cgroups(pid_t pid)
         */
        if (is_cgroup_mode_unified()) {
                pthread_rwlock_rdlock(&cg_mount_table_lock);
-               cg_build_path_locked(info[idx].cgrp_path, cgroup_path, NULL);
+               cg_build_path_locked(info[idx].cgrp_path, cgrp_path, NULL);
                pthread_rwlock_unlock(&cg_mount_table_lock);
 
-               snprintf(cgroup_proc_path, FILENAME_MAX + 14, "%s/cgroup.procs", cgroup_path);
-               ret = attach_task_pid(cgroup_proc_path, pid);
+               snprintf(cgrp_proc_path, FILENAME_MAX + 14, "%s/cgroup.procs", cgrp_path);
+               ret = attach_task_pid(cgrp_proc_path, pid);
                return ret;
        }
 
        for (idx = 0; info[idx].ctrl_name[0] != '\0'; idx++) {
                /* find the systemd cgroup path */
                if (!strcmp(info[idx].ctrl_name, "name=systemd")) {
-                       find_mnt_point("name=systemd", &cgrp_proc_path);
-                       if (!cgrp_proc_path) {
+                       find_mnt_point("name=systemd", &_cgrp_proc_path);
+                       if (!_cgrp_proc_path) {
                                err("Unable find name=systemd cgroup path\n");
                                return -1;
                        }
 
-                       snprintf(cgroup_proc_path, FILENAME_MAX + 14, "%s/%s/cgroup.procs",
-                                cgrp_proc_path, info[idx].cgrp_path);
-                       free(cgrp_proc_path);
+                       snprintf(cgrp_proc_path, FILENAME_MAX + 14, "%s/%s/cgroup.procs",
+                                _cgrp_proc_path, info[idx].cgrp_path);
+                       free(_cgrp_proc_path);
 
                /* find the unified cgroup path */
                } else if (is_cgroup_mode_hybrid() &&
                           !strcmp(info[idx].ctrl_name, "unified")) {
-                       find_mnt_point("unified cgroup2", &cgrp_proc_path);
-                       if (!cgrp_proc_path) {
+                       find_mnt_point("unified cgroup2", &_cgrp_proc_path);
+                       if (!_cgrp_proc_path) {
                                err("Unable find unified cgroup path\n");
                                return -1;
                        }
 
-                       snprintf(cgroup_proc_path, FILENAME_MAX + 14, "%s/%s/cgroup.procs",
-                               cgrp_proc_path, info[idx].cgrp_path);
-                       free(cgrp_proc_path);
+                       snprintf(cgrp_proc_path, FILENAME_MAX + 14, "%s/%s/cgroup.procs",
+                               _cgrp_proc_path, info[idx].cgrp_path);
+                       free(_cgrp_proc_path);
 
                /* find other controller hierarchy path */
                } else {
                        pthread_rwlock_rdlock(&cg_mount_table_lock);
-                       cg_build_path_locked(info[idx].cgrp_path, cgroup_path, info[idx].ctrl_name);
+                       cg_build_path_locked(info[idx].cgrp_path, cgrp_path, info[idx].ctrl_name);
                        pthread_rwlock_unlock(&cg_mount_table_lock);
 
-                       snprintf(cgroup_proc_path, FILENAME_MAX + 14, "%s/cgroup.procs",
-                               cgroup_path);
+                       snprintf(cgrp_proc_path, FILENAME_MAX + 14, "%s/cgroup.procs", cgrp_path);
                }
 
                /* record the error and continue */
-               ret = attach_task_pid(cgroup_proc_path, pid);
+               ret = attach_task_pid(cgrp_proc_path, pid);
                if (ret)
                        err = -1;
        }
index ac28a342f22f8a88eb2e578eb280e3da6a5cc1ee..88d2cad4581dc9bb282adc04afb2d85b023a8be6 100644 (file)
@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
        mode_t file_mode = NO_PERMS;
        mode_t dir_mode = NO_PERMS;
 
-       struct cgroup *default_group = NULL;
+       struct cgroup *default_cgrp = NULL;
        int filem_change = 0;
        int dirm_change = 0;
        int ret, error = 0;
@@ -153,23 +153,23 @@ int main(int argc, char *argv[])
        }
 
        /* set default permissions */
-       default_group = cgroup_new_cgroup("default");
-       if (!default_group) {
+       default_cgrp = cgroup_new_cgroup("default");
+       if (!default_cgrp) {
                error = -1;
                err("%s: cannot create default cgroup\n", argv[0]);
                goto err;
        }
 
-       error = cgroup_set_uid_gid(default_group, tuid, tgid, auid, agid);
+       error = cgroup_set_uid_gid(default_cgrp, tuid, tgid, auid, agid);
        if (error) {
                err("%s: cannot set default UID and GID: %s\n", argv[0], cgroup_strerror(error));
                goto free_cgroup;
        }
 
        if (dirm_change | filem_change)
-               cgroup_set_permissions(default_group, dir_mode, file_mode, tasks_mode);
+               cgroup_set_permissions(default_cgrp, dir_mode, file_mode, tasks_mode);
 
-       error = cgroup_config_set_default(default_group);
+       error = cgroup_config_set_default(default_cgrp);
        if (error) {
                err("%s: cannot set config parser defaults: %s\n", argv[0],
                    cgroup_strerror(error));
@@ -187,7 +187,7 @@ int main(int argc, char *argv[])
        }
 
 free_cgroup:
-       cgroup_free(&default_group);
+       cgroup_free(&default_cgrp);
 err:
        cgroup_string_list_free(&cfg_files);
 
index 705d0438ce4b09f6229761ff5553d81eaf879baa..c677d6e0f91a2b509360c01d7a41a9de68545ef3 100644 (file)
@@ -53,7 +53,7 @@ static void usage(int status, const char *program_name)
 }
 
 #ifdef WITH_SYSTEMD
-static int create_systemd_scope(struct cgroup * const cg, const char * const prog_name,
+static int create_systemd_scope(struct cgroup * const cgrp, const char * const prog_name,
                                int set_default, pid_t pid)
 {
        struct cgroup_systemd_scope_opts opts;
@@ -68,17 +68,17 @@ static int create_systemd_scope(struct cgroup * const cg, const char * const pro
 
        opts.pid = pid;
 
-       ret = cgroup_create_scope2(cg, 0, &opts);
+       ret = cgroup_create_scope2(cgrp, 0, &opts);
        if (!ret && set_default) {
-               scope = strstr(cg->name, "/");
+               scope = strstr(cgrp->name, "/");
                if (!scope) {
                        err("%s: Invalid scope name %s, expected <slice>/<scope>\n",
-                           prog_name, cg->name);
+                           prog_name, cgrp->name);
                        ret = ECGINVAL;
                        goto err;
                }
-               len = strlen(cg->name) - strlen(scope);
-               strncpy(slice, cg->name, FILENAME_MAX - 1);
+               len = strlen(cgrp->name) - strlen(scope);
+               strncpy(slice, cgrp->name, FILENAME_MAX - 1);
                slice[len] = '\0';
                scope++;
 
@@ -87,9 +87,8 @@ static int create_systemd_scope(struct cgroup * const cg, const char * const pro
                 * cgroup_write_systemd_default_cgroup() returns 0 on failure
                 */
                if (ret == 0) {
-                       err("%s: failed to write default %s/%s to ",
+                       err("%s: failed to write default %s/%s to /var/run/libcgroup/systemd\n",
                            prog_name, slice, scope);
-                       err("/var/run/libcgroup/systemd\n");
                        ret = ECGINVAL;
                        goto err;
                }
@@ -105,7 +104,7 @@ err:
        return ret;
 }
 #else
-static int create_systemd_scope(struct cgroup * const cg, const char * const prog_name,
+static int create_systemd_scope(struct cgroup * const cgrp, const char * const prog_name,
                                int set_default, pid_t pid)
 {
        return ECGINVAL;
@@ -140,9 +139,9 @@ int main(int argc, char *argv[])
        int create_scope = 0;
        pid_t scope_pid = -1;
 
-       struct cgroup_group_spec **cgroup_list;
+       struct cgroup_group_spec **cgrp_list;
        struct cgroup_controller *cgc;
-       struct cgroup *cgroup;
+       struct cgroup *cgrp;
 
        /* approximation of max. numbers of groups that will be created */
        int capacity = argc;
@@ -164,8 +163,8 @@ int main(int argc, char *argv[])
                exit(EXIT_BADARGS);
        }
 
-       cgroup_list = calloc(capacity, sizeof(struct cgroup_group_spec *));
-       if (cgroup_list == NULL) {
+       cgrp_list = calloc(capacity, sizeof(struct cgroup_group_spec *));
+       if (cgrp_list == NULL) {
                err("%s: out of memory\n", argv[0]);
                ret = -1;
                goto err;
@@ -211,7 +210,7 @@ int main(int argc, char *argv[])
                                goto err;
                        break;
                case 'g':
-                       ret = parse_cgroup_spec(cgroup_list, optarg, capacity);
+                       ret = parse_cgroup_spec(cgrp_list, optarg, capacity);
                        if (ret) {
                                err("%s: cgroup controller and path parsing failed (%s)\n",
                                    argv[0], argv[optind]);
@@ -285,42 +284,42 @@ int main(int argc, char *argv[])
 
        /* for each new cgroup */
        for (i = 0; i < capacity; i++) {
-               if (!cgroup_list[i])
+               if (!cgrp_list[i])
                        break;
 
                /* create the new cgroup structure */
-               cgroup = cgroup_new_cgroup(cgroup_list[i]->path);
-               if (!cgroup) {
+               cgrp = cgroup_new_cgroup(cgrp_list[i]->path);
+               if (!cgrp) {
                        ret = ECGFAIL;
                        err("%s: can't add new cgroup: %s\n", argv[0], cgroup_strerror(ret));
                        goto err;
                }
 
                /* set uid and gid for the new cgroup based on input options */
-               ret = cgroup_set_uid_gid(cgroup, tuid, tgid, auid, agid);
+               ret = cgroup_set_uid_gid(cgrp, tuid, tgid, auid, agid);
                if (ret)
                        goto err;
 
                /* add controllers to the new cgroup */
                j = 0;
-               while (cgroup_list[i]->controllers[j]) {
-                       if (strcmp(cgroup_list[i]->controllers[j], "*") == 0) {
+               while (cgrp_list[i]->controllers[j]) {
+                       if (strcmp(cgrp_list[i]->controllers[j], "*") == 0) {
                                /* it is meta character, add all controllers */
-                               ret = cgroup_add_all_controllers(cgroup);
+                               ret = cgroup_add_all_controllers(cgrp);
                                if (ret != 0) {
                                        ret = ECGINVAL;
                                        err("%s: can't add all controllers\n", argv[0]);
-                                       cgroup_free(&cgroup);
+                                       cgroup_free(&cgrp);
                                        goto err;
                                }
                        } else {
-                               cgc = cgroup_add_controller(cgroup,
-                                       cgroup_list[i]->controllers[j]);
+                               cgc = cgroup_add_controller(cgrp,
+                                       cgrp_list[i]->controllers[j]);
                                if (!cgc) {
                                        ret = ECGINVAL;
                                        err("%s: controller %s can't be add\n", argv[0],
-                                           cgroup_list[i]->controllers[j]);
-                                       cgroup_free(&cgroup);
+                                           cgrp_list[i]->controllers[j]);
+                                       cgroup_free(&cgrp);
                                        goto err;
                                }
                        }
@@ -329,28 +328,28 @@ int main(int argc, char *argv[])
 
                /* all variables set so create cgroup */
                if (dirm_change | filem_change)
-                       cgroup_set_permissions(cgroup, dir_mode, file_mode, tasks_mode);
+                       cgroup_set_permissions(cgrp, dir_mode, file_mode, tasks_mode);
 
                if (create_scope)
-                       ret = create_systemd_scope(cgroup, argv[0], set_default_scope, scope_pid);
+                       ret = create_systemd_scope(cgrp, argv[0], set_default_scope, scope_pid);
                else
-                       ret = cgroup_create_cgroup(cgroup, 0);
+                       ret = cgroup_create_cgroup(cgrp, 0);
                if (ret) {
-                       err("%s: can't create cgroup %s: %s\n", argv[0], cgroup->name,
+                       err("%s: can't create cgroup %s: %s\n", argv[0], cgrp->name,
                            cgroup_strerror(ret));
-                       cgroup_free(&cgroup);
+                       cgroup_free(&cgrp);
                        goto err;
                }
-               cgroup_free(&cgroup);
+               cgroup_free(&cgrp);
        }
 
 err:
-       if (cgroup_list) {
+       if (cgrp_list) {
                for (i = 0; i < capacity; i++) {
-                       if (cgroup_list[i])
-                               cgroup_free_group_spec(cgroup_list[i]);
+                       if (cgrp_list[i])
+                               cgroup_free_group_spec(cgrp_list[i]);
                }
-               free(cgroup_list);
+               free(cgrp_list);
        }
 
        return ret;
index cf135d8cc739481819b836539f673d3f0d78566d..88144a73397391ee2673abf45beac863c5789988 100644 (file)
@@ -116,10 +116,10 @@ int main(int argc, char *argv[])
 #ifdef WITH_SYSTEMD
        int ignore_default_systemd_delegate_slice = 0;
 #endif
-       struct cgroup_group_spec **cgroup_list = NULL;
+       struct cgroup_group_spec **cgrp_list = NULL;
        struct ext_cgroup_record *ecg_list = NULL;
        struct cgroup_controller *cgc;
-       struct cgroup *cgroup;
+       struct cgroup *cgrp;
 
        int final_ret = 0;
        int counter = 0;
@@ -141,8 +141,8 @@ int main(int argc, char *argv[])
                goto err;
        }
 
-       cgroup_list = calloc(argc, sizeof(struct cgroup_group_spec *));
-       if (cgroup_list == NULL) {
+       cgrp_list = calloc(argc, sizeof(struct cgroup_group_spec *));
+       if (cgrp_list == NULL) {
                err("%s: out of memory\n", argv[0]);
                ret = -1;
                goto err;
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
                        flags |= CGFLAG_DELETE_RECURSIVE;
                        break;
                case 'g':
-                       ret = parse_cgroup_spec(cgroup_list, optarg, argc);
+                       ret = parse_cgroup_spec(cgrp_list, optarg, argc);
                        if (ret != 0) {
                                err("%s: error parsing cgroup '%s'", argv[0], optarg);
                                ret = EXIT_BADARGS;
@@ -195,7 +195,7 @@ int main(int argc, char *argv[])
 
        /* parse groups on command line */
        for (i = optind; i < argc; i++) {
-               ret = parse_cgroup_spec(cgroup_list, argv[i], argc);
+               ret = parse_cgroup_spec(cgrp_list, argv[i], argc);
                if (ret != 0) {
                        err("%s: error parsing cgroup '%s'\n", argv[0], argv[i]);
                        ret = EXIT_BADARGS;
@@ -205,12 +205,12 @@ int main(int argc, char *argv[])
 
        /* for each cgroup to be deleted */
        for (i = 0; i < argc; i++) {
-               if (!cgroup_list[i])
+               if (!cgrp_list[i])
                        break;
 
                /* create the new cgroup structure */
-               cgroup = cgroup_new_cgroup(cgroup_list[i]->path);
-               if (!cgroup) {
+               cgrp = cgroup_new_cgroup(cgrp_list[i]->path);
+               if (!cgrp) {
                        ret = ECGFAIL;
                        err("%s: can't create new cgroup: %s\n", argv[0], cgroup_strerror(ret));
                        goto err;
@@ -218,7 +218,7 @@ int main(int argc, char *argv[])
 
                /* add controllers to the cgroup */
                j = 0;
-               while (cgroup_list[i]->controllers[j]) {
+               while (cgrp_list[i]->controllers[j]) {
                        skip = 0;
                        /*
                         * save controller name, cg name and hierarchy
@@ -241,11 +241,10 @@ int main(int argc, char *argv[])
                        }
 
                        strncpy(ecg_list[counter].controller,
-                               cgroup_list[i]->controllers[j], FILENAME_MAX);
+                               cgrp_list[i]->controllers[j], FILENAME_MAX);
                        ecg_list[counter].controller[FILENAME_MAX - 1] = '\0';
 
-                       strncpy(ecg_list[counter].name,
-                               cgroup_list[i]->path, FILENAME_MAX);
+                       strncpy(ecg_list[counter].name, cgrp_list[i]->path, FILENAME_MAX);
                        ecg_list[counter].name[FILENAME_MAX - 1] = '\0';
 
                        ret = skip_add_controller(counter, &skip, ecg_list);
@@ -257,12 +256,12 @@ int main(int argc, char *argv[])
                                goto next;
                        }
 
-                       cgc = cgroup_add_controller(cgroup, cgroup_list[i]->controllers[j]);
+                       cgc = cgroup_add_controller(cgrp, cgrp_list[i]->controllers[j]);
                        if (!cgc) {
                                ret = ECGFAIL;
                                err("%s: controller %s can't be added\n", argv[0],
-                                   cgroup_list[i]->controllers[j]);
-                               cgroup_free(&cgroup);
+                                   cgrp_list[i]->controllers[j]);
+                               cgroup_free(&cgrp);
                                goto err;
                        }
 next:
@@ -270,14 +269,14 @@ next:
                        j++;
                }
 
-               ret = cgroup_delete_cgroup_ext(cgroup, flags);
+               ret = cgroup_delete_cgroup_ext(cgrp, flags);
                /* Remember the errors and continue, try to remove all groups. */
                if (ret != 0) {
-                       err("%s: cannot remove group '%s': %s\n", argv[0], cgroup->name,
+                       err("%s: cannot remove group '%s': %s\n", argv[0], cgrp->name,
                            cgroup_strerror(ret));
                        final_ret = ret;
                }
-               cgroup_free(&cgroup);
+               cgroup_free(&cgrp);
        }
 
        ret = final_ret;
@@ -286,12 +285,12 @@ err:
        if (ecg_list)
                free(ecg_list);
 
-       if (cgroup_list) {
+       if (cgrp_list) {
                for (i = 0; i < argc; i++) {
-                       if (cgroup_list[i])
-                               cgroup_free_group_spec(cgroup_list[i]);
+                       if (cgrp_list[i])
+                               cgroup_free_group_spec(cgrp_list[i]);
                }
-               free(cgroup_list);
+               free(cgrp_list);
        }
 
        return ret;
index 10b88c20dba3483c1fc7c0e9f92fc1c0662d077d..448d3ff951c1ba9c8180e6415115d66bbf14311f 100644 (file)
@@ -69,7 +69,7 @@ static void usage(int status, const char *program_name)
 
 int main(int argc, char *argv[])
 {
-       struct cgroup_group_spec *cgroup_list[CG_HIER_MAX];
+       struct cgroup_group_spec *cgrp_list[CG_HIER_MAX];
 #ifdef WITH_SYSTEMD
        int ignore_default_systemd_delegate_slice = 0;
 #endif
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
        pid_t pid;
        int c;
 
-       memset(cgroup_list, 0, sizeof(cgroup_list));
+       memset(cgrp_list, 0, sizeof(cgrp_list));
 #ifdef WITH_SYSTEMD
        while ((c = getopt_long(argc, argv, "+g:shbr", longopts, NULL)) > 0) {
                switch (c) {
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
                switch (c) {
 #endif
                case 'g':
-                       ret = parse_cgroup_spec(cgroup_list, optarg, CG_HIER_MAX);
+                       ret = parse_cgroup_spec(cgrp_list, optarg, CG_HIER_MAX);
                        if (ret) {
                                err("cgroup controller and path parsing failed\n");
                                exit(EXIT_BADARGS);
@@ -173,11 +173,11 @@ int main(int argc, char *argv[])
                 * and controllers
                 */
                for (i = 0; i < CG_HIER_MAX; i++) {
-                       if (!cgroup_list[i])
+                       if (!cgrp_list[i])
                                break;
 
-                       ret = cgroup_change_cgroup_path(cgroup_list[i]->path, pid,
-                               (const char *const*) cgroup_list[i]->controllers);
+                       ret = cgroup_change_cgroup_path(cgrp_list[i]->path, pid,
+                               (const char *const*) cgrp_list[i]->controllers);
                        if (ret) {
                                err("cgroup change of group failed\n");
                                return ret;
@@ -265,8 +265,8 @@ static pid_t find_scope_pid(pid_t pid)
 {
        pid_t _scope_pid = -1, scope_pid = -1;
        char ctrl_name[CONTROL_NAMELEN_MAX];
-       char cgroup_name[FILENAME_MAX];
        char scope_name[FILENAME_MAX];
+       char cgrp_name[FILENAME_MAX];
        int found_systemd_cgrp = 0;
        int found_unified_cgrp = 0;
        char buffer[FILENAME_MAX];
@@ -291,9 +291,9 @@ static pid_t find_scope_pid(pid_t pid)
 
                /* read according to the cgroup mode */
                if (strstr(buffer, "::"))
-                       ret = sscanf(buffer, "%d::%4096s\n", &idx, cgroup_name);
+                       ret = sscanf(buffer, "%d::%4096s\n", &idx, cgrp_name);
                else
-                       ret = sscanf(buffer, "%d:%[^:]:%4096s\n", &idx, ctrl_name, cgroup_name);
+                       ret = sscanf(buffer, "%d:%[^:]:%4096s\n", &idx, ctrl_name, cgrp_name);
 
                if (ret != 2 && ret != 3) {
                        err("Unrecognized cgroup file format: %s\n", buffer);
@@ -311,12 +311,12 @@ static pid_t find_scope_pid(pid_t pid)
                }
 
                /* skip if the cgroup path doesn't have systemd scope format */
-               if (strstr(cgroup_name, ".scope") == NULL ||
-                   strstr(cgroup_name, ".slice") == NULL)
+               if (strstr(cgrp_name, ".scope") == NULL ||
+                   strstr(cgrp_name, ".slice") == NULL)
                        continue;
 
                /* skip if we have already searched cgroup for idle_thread */
-               if (is_scope_parsed(cgroup_name))
+               if (is_scope_parsed(cgrp_name))
                        continue;
 
                /* cgroup v1 might have shared mount points cpu,cpuacct */
@@ -327,11 +327,11 @@ static pid_t find_scope_pid(pid_t pid)
                }
 
                if (ret == 2)
-                       ret = cgroup_get_procs(cgroup_name, NULL, &pids, &size);
+                       ret = cgroup_get_procs(cgrp_name, NULL, &pids, &size);
                else
-                       ret = cgroup_get_procs(cgroup_name, ctrl_name, &pids, &size);
+                       ret = cgroup_get_procs(cgrp_name, ctrl_name, &pids, &size);
                if (ret) {
-                       err("Failed to read cgroup.procs of cgroup: %s\n", cgroup_name + 1);
+                       err("Failed to read cgroup.procs of cgroup: %s\n", cgrp_name + 1);
                        goto out;
                }
 
@@ -351,7 +351,7 @@ static pid_t find_scope_pid(pid_t pid)
                         * ../systemd/<slice>/<scope>/cgroup.procs (legacy/hybrid)
                         * ../unified/<slice>/<scope>/cgroup.procs (hybrid)
                         */
-                       snprintf(scope_name, FILENAME_MAX, "%s", cgroup_name);
+                       snprintf(scope_name, FILENAME_MAX, "%s", cgrp_name);
                        scope_pid = _scope_pid;
                        continue;
                }
@@ -402,8 +402,8 @@ out:
 static void find_mnt_point(const char * const controller, char **mnt_point)
 {
        char proc_mount[] = "/proc/mounts";
-       char cgroup_path[FILENAME_MAX];
        char buffer[FILENAME_MAX * 2];
+       char cgrp_path[FILENAME_MAX];
        FILE *proc_mount_f = NULL;
        int ret;
 
@@ -420,15 +420,15 @@ static void find_mnt_point(const char * const controller, char **mnt_point)
                if (!strstr(buffer, controller))
                        continue;
 
-               ret = sscanf(buffer, "%*s %4096s\n", cgroup_path);
+               ret = sscanf(buffer, "%*s %4096s\n", cgrp_path);
                if (ret != 1) {
                        err("Failed during read of %s:%s\n", proc_mount, strerror(errno));
                        goto out;
                }
 
-               *mnt_point = strdup(cgroup_path);
+               *mnt_point = strdup(cgrp_path);
                if (!*mnt_point)
-                       err("strdup of %s failed\n", cgroup_path);
+                       err("strdup of %s failed\n", cgrp_path);
                break;
        }
 
@@ -439,26 +439,26 @@ out:
 
 static int write_systemd_unified(const char * const scope_name)
 {
-       char cgroup_procs_path[FILENAME_MAX * 2 + 25];
-       FILE *cgroup_systemd_path_f = NULL;
-       FILE *cgroup_unified_path_f = NULL;
-       char *cgroup_name = NULL;
+       char cgrp_procs_path[FILENAME_MAX * 2 + 25];
+       FILE *cgrp_systemd_path_f = NULL;
+       FILE *cgrp_unified_path_f = NULL;
+       char *cgrp_name = NULL;
        pid_t pid;
 
        /* construct the systemd cgroup path, by parsing /proc/mounts */
-       find_mnt_point("name=systemd ", &cgroup_name);
-       if (!cgroup_name) {
+       find_mnt_point("name=systemd ", &cgrp_name);
+       if (!cgrp_name) {
                err("Unable find name=systemd cgroup path\n");
                return -1;
        }
 
-       snprintf(cgroup_procs_path, sizeof(cgroup_procs_path), "%s/%s/cgroup.procs",
-                cgroup_name, scope_name);
-       free(cgroup_name);
+       snprintf(cgrp_procs_path, sizeof(cgrp_procs_path), "%s/%s/cgroup.procs",
+                cgrp_name, scope_name);
+       free(cgrp_name);
 
-       cgroup_systemd_path_f = fopen(cgroup_procs_path, "we");
-       if (!cgroup_systemd_path_f) {
-               err("Failed to open %s\n", cgroup_procs_path);
+       cgrp_systemd_path_f = fopen(cgrp_procs_path, "we");
+       if (!cgrp_systemd_path_f) {
+               err("Failed to open %s\n", cgrp_procs_path);
                return -1;
        }
 
@@ -467,37 +467,37 @@ static int write_systemd_unified(const char * const scope_name)
                 * construct the unified cgroup path, by parsing
                 * /proc/mounts
                 */
-               find_mnt_point("unified cgroup2", &cgroup_name);
-               if (!cgroup_name) {
+               find_mnt_point("unified cgroup2", &cgrp_name);
+               if (!cgrp_name) {
                        err("Unable find unified cgroup path\n");
-                       fclose(cgroup_systemd_path_f);
+                       fclose(cgrp_systemd_path_f);
                        return -1;
                }
 
-               snprintf(cgroup_procs_path, sizeof(cgroup_procs_path), "%s/%s/cgroup.procs",
-                               cgroup_name, scope_name);
-               free(cgroup_name);
+               snprintf(cgrp_procs_path, sizeof(cgrp_procs_path), "%s/%s/cgroup.procs",
+                               cgrp_name, scope_name);
+               free(cgrp_name);
 
-               cgroup_unified_path_f = fopen(cgroup_procs_path, "we");
-               if (!cgroup_unified_path_f) {
-                       err("Failed to open %s\n", cgroup_procs_path);
-                       fclose(cgroup_systemd_path_f);
+               cgrp_unified_path_f = fopen(cgrp_procs_path, "we");
+               if (!cgrp_unified_path_f) {
+                       err("Failed to open %s\n", cgrp_procs_path);
+                       fclose(cgrp_systemd_path_f);
                        return -1;
                }
        }
 
        pid = getpid();
 
-       fprintf(cgroup_systemd_path_f, "%d", pid);
-       fflush(cgroup_systemd_path_f);
-       fclose(cgroup_systemd_path_f);
+       fprintf(cgrp_systemd_path_f, "%d", pid);
+       fflush(cgrp_systemd_path_f);
+       fclose(cgrp_systemd_path_f);
 
        if (!is_cgroup_mode_hybrid())
                return 0;
 
-       fprintf(cgroup_unified_path_f, "%d", pid);
-       fflush(cgroup_unified_path_f);
-       fclose(cgroup_unified_path_f);
+       fprintf(cgrp_unified_path_f, "%d", pid);
+       fflush(cgrp_unified_path_f);
+       fclose(cgrp_unified_path_f);
 
        return 0;
 }
index b590aa6a7c41f4c08de45ba3ecbb09adf49ff8f7..ab153ccc30f3605c7c329b12d1301a92a2f68060 100644 (file)
@@ -71,33 +71,33 @@ static int get_controller_from_name(const char * const name, char **controller)
        return 0;
 }
 
-static int create_cg(struct cgroup **cg_list[], int * const cg_list_len)
+static int create_cgrp(struct cgroup **cgrp_list[], int * const cgrp_list_len)
 {
-       *cg_list = realloc(*cg_list, ((*cg_list_len) + 1) * sizeof(struct cgroup *));
-       if ((*cg_list) == NULL)
+       *cgrp_list = realloc(*cgrp_list, ((*cgrp_list_len) + 1) * sizeof(struct cgroup *));
+       if ((*cgrp_list) == NULL)
                return ECGCONTROLLERCREATEFAILED;
 
-       memset(&(*cg_list)[*cg_list_len], 0, sizeof(struct cgroup *));
+       memset(&(*cgrp_list)[*cgrp_list_len], 0, sizeof(struct cgroup *));
 
-       (*cg_list)[*cg_list_len] = cgroup_new_cgroup("");
-       if ((*cg_list)[*cg_list_len] == NULL)
+       (*cgrp_list)[*cgrp_list_len] = cgroup_new_cgroup("");
+       if ((*cgrp_list)[*cgrp_list_len] == NULL)
                return ECGCONTROLLERCREATEFAILED;
 
-       (*cg_list_len)++;
+       (*cgrp_list_len)++;
 
        return 0;
 }
 
-static int parse_a_flag(struct cgroup **cg_list[], int * const cg_list_len)
+static int parse_a_flag(struct cgroup **cgrp_list[], int * const cgrp_list_len)
 {
        struct cgroup_mount_point controller;
        struct cgroup_controller *cgc;
-       struct cgroup *cg = NULL;
+       struct cgroup *cgrp = NULL;
        void *handle;
        int ret = 0;
 
-       if ((*cg_list_len) == 0) {
-               ret = create_cg(cg_list, cg_list_len);
+       if ((*cgrp_list_len) == 0) {
+               ret = create_cgrp(cgrp_list, cgrp_list_len);
                if (ret)
                        goto out;
        }
@@ -107,13 +107,13 @@ static int parse_a_flag(struct cgroup **cg_list[], int * const cg_list_len)
         * an optarg at the end with no flag.  Let's temporarily populate
         * the first cgroup with the requested control values.
         */
-       cg = (*cg_list)[0];
+       cgrp = (*cgrp_list)[0];
 
        ret = cgroup_get_controller_begin(&handle, &controller);
        while (ret == 0) {
-               cgc = cgroup_get_controller(cg, controller.name);
+               cgc = cgroup_get_controller(cgrp, controller.name);
                if (!cgc) {
-                       cgc = cgroup_add_controller(cg, controller.name);
+                       cgc = cgroup_add_controller(cgrp, controller.name);
                        if (!cgc) {
                                err("cgget: cannot find controller '%s'\n", controller.name);
                                ret = ECGOTHER;
@@ -139,16 +139,16 @@ out:
        return ret;
 }
 
-static int parse_r_flag(struct cgroup **cg_list[], int * const cg_list_len,
+static int parse_r_flag(struct cgroup **cgrp_list[], int * const cgrp_list_len,
                        const char * const cntl_value)
 {
        char *cntl_value_controller = NULL;
        struct cgroup_controller *cgc;
-       struct cgroup *cg = NULL;
+       struct cgroup *cgrp = NULL;
        int ret = 0;
 
-       if ((*cg_list_len) == 0) {
-               ret = create_cg(cg_list, cg_list_len);
+       if ((*cgrp_list_len) == 0) {
+               ret = create_cgrp(cgrp_list, cgrp_list_len);
                if (ret)
                        goto out;
        }
@@ -158,15 +158,15 @@ static int parse_r_flag(struct cgroup **cg_list[], int * const cg_list_len,
         * an optarg at the end with no flag.  Let's temporarily populate
         * the first cgroup with the requested control values.
         */
-       cg = (*cg_list)[0];
+       cgrp = (*cgrp_list)[0];
 
        ret = get_controller_from_name(cntl_value, &cntl_value_controller);
        if (ret)
                goto out;
 
-       cgc = cgroup_get_controller(cg, cntl_value_controller);
+       cgc = cgroup_get_controller(cgrp, cntl_value_controller);
        if (!cgc) {
-               cgc = cgroup_add_controller(cg, cntl_value_controller);
+               cgc = cgroup_add_controller(cgrp, cntl_value_controller);
                if (!cgc) {
                        err("cgget: cannot find controller '%s'\n", cntl_value_controller);
                        ret = ECGOTHER;
@@ -183,20 +183,20 @@ out:
        return ret;
 }
 
-static int parse_g_flag_no_colon(struct cgroup **cg_list[], int * const cg_list_len,
+static int parse_g_flag_no_colon(struct cgroup **cgrp_list[], int * const cgrp_list_len,
                                 const char * const ctrl_str)
 {
        struct cgroup_controller *cgc;
-       struct cgroup *cg = NULL;
+       struct cgroup *cgrp = NULL;
        int ret = 0;
 
-       if ((*cg_list_len) > 1) {
+       if ((*cgrp_list_len) > 1) {
                ret = ECGMAXVALUESEXCEEDED;
                goto out;
        }
 
-       if ((*cg_list_len) == 0) {
-               ret = create_cg(cg_list, cg_list_len);
+       if ((*cgrp_list_len) == 0) {
+               ret = create_cgrp(cgrp_list, cgrp_list_len);
                if (ret)
                        goto out;
        }
@@ -206,11 +206,11 @@ static int parse_g_flag_no_colon(struct cgroup **cg_list[], int * const cg_list_
         * will be an optarg at the end with no flag.  Let's temporarily
         * populate the first cgroup with the requested control values.
         */
-       cg = *cg_list[0];
+       cgrp = *cgrp_list[0];
 
-       cgc = cgroup_get_controller(cg, ctrl_str);
+       cgc = cgroup_get_controller(cgrp, ctrl_str);
        if (!cgc) {
-               cgc = cgroup_add_controller(cg, ctrl_str);
+               cgc = cgroup_add_controller(cgrp, ctrl_str);
                if (!cgc) {
                        err("cgget: cannot find controller '%s'\n", ctrl_str);
                        ret = ECGOTHER;
@@ -222,18 +222,18 @@ out:
        return ret;
 }
 
-static int split_cgroup_name(const char * const ctrl_str, char *cg_name)
+static int split_cgroup_name(const char * const ctrl_str, char *cgrp_name)
 {
        char *colon;
 
        colon = strchr(ctrl_str, ':');
        if (colon == NULL) {
                /* ctrl_str doesn't contain a ":" */
-               cg_name[0] = '\0';
+               cgrp_name[0] = '\0';
                return ECGINVAL;
        }
 
-       strncpy(cg_name, &colon[1], FILENAME_MAX - 1);
+       strncpy(cgrp_name, &colon[1], FILENAME_MAX - 1);
 
        return 0;
 }
@@ -277,22 +277,22 @@ out:
        return ret;
 }
 
-static int parse_g_flag_with_colon(struct cgroup **cg_list[], int * const cg_list_len,
+static int parse_g_flag_with_colon(struct cgroup **cgrp_list[], int * const cgrp_list_len,
                                   const char * const ctrl_str)
 {
        struct cgroup_controller *cgc;
-       struct cgroup *cg = NULL;
+       struct cgroup *cgrp = NULL;
        char **controllers = NULL;
        int controllers_len = 0;
        int i, ret = 0;
 
-       ret = create_cg(cg_list, cg_list_len);
+       ret = create_cgrp(cgrp_list, cgrp_list_len);
        if (ret)
                goto out;
 
-       cg = (*cg_list)[(*cg_list_len) - 1];
+       cgrp = (*cgrp_list)[(*cgrp_list_len) - 1];
 
-       ret = split_cgroup_name(ctrl_str, cg->name);
+       ret = split_cgroup_name(ctrl_str, cgrp->name);
        if (ret)
                goto out;
 
@@ -301,9 +301,9 @@ static int parse_g_flag_with_colon(struct cgroup **cg_list[], int * const cg_lis
                goto out;
 
        for (i = 0; i < controllers_len; i++) {
-               cgc = cgroup_get_controller(cg, controllers[i]);
+               cgc = cgroup_get_controller(cgrp, controllers[i]);
                if (!cgc) {
-                       cgc = cgroup_add_controller(cg, controllers[i]);
+                       cgc = cgroup_add_controller(cgrp, controllers[i]);
                        if (!cgc) {
                                err("cgget: cannot find controller '%s'\n", controllers[i]);
                                ret = ECGOTHER;
@@ -319,17 +319,17 @@ out:
        return ret;
 }
 
-static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[],
-                         int * const cg_list_len, bool first_cg_is_dummy)
+static int parse_opt_args(int argc, char *argv[], struct cgroup **cgrp_list[],
+                         int * const cgrp_list_len, bool first_cgrp_is_dummy)
 {
-       struct cgroup *cg = NULL;
+       struct cgroup *cgrp = NULL;
        int ret = 0;
 
        /*
         * The first cgroup was temporarily populated and requires the
         * user to provide a cgroup name as an opt
         */
-       if (argv[optind] == NULL && first_cg_is_dummy) {
+       if (argv[optind] == NULL && first_cgrp_is_dummy) {
                usage(1, argv[0]);
                exit(EXIT_BADARGS);
        }
@@ -343,50 +343,50 @@ static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[],
         * Example of a command that will hit this code:
         *      $ cgget -g cpu:mycgroup mycgroup
         */
-       if (argv[optind] != NULL && (*cg_list_len) > 0 &&
-           strcmp((*cg_list)[0]->name, "") != 0) {
+       if (argv[optind] != NULL && (*cgrp_list_len) > 0 &&
+           strcmp((*cgrp_list)[0]->name, "") != 0) {
                usage(1, argv[0]);
                exit(EXIT_BADARGS);
        }
 
        while (argv[optind] != NULL) {
-               if ((*cg_list_len) > 0)
-                       cg = (*cg_list)[(*cg_list_len) - 1];
+               if ((*cgrp_list_len) > 0)
+                       cgrp = (*cgrp_list)[(*cgrp_list_len) - 1];
                else
-                       cg = NULL;
+                       cgrp = NULL;
 
-               if ((*cg_list_len) == 0) {
+               if ((*cgrp_list_len) == 0) {
                        /*
                         * The user didn't provide a '-r' or '-g' flag.
                         * The parse_a_flag() function can be reused here
                         * because we both have the same use case - gather
                         * all the data about this particular cgroup.
                         */
-                       ret = parse_a_flag(cg_list, cg_list_len);
+                       ret = parse_a_flag(cgrp_list, cgrp_list_len);
                        if (ret)
                                goto out;
 
-                       strncpy((*cg_list)[(*cg_list_len) - 1]->name, argv[optind],
-                               sizeof((*cg_list)[(*cg_list_len) - 1]->name) - 1);
-               } else if (cg != NULL && strlen(cg->name) == 0) {
+                       strncpy((*cgrp_list)[(*cgrp_list_len) - 1]->name, argv[optind],
+                               sizeof((*cgrp_list)[(*cgrp_list_len) - 1]->name) - 1);
+               } else if (cgrp != NULL && strlen(cgrp->name) == 0) {
                        /*
                         * this cgroup was created based upon control/value
                         * pairs or with a -g <controller> option.  we'll
                         * populate it with the parameter provided by the user
                         */
-                       strncpy(cg->name, argv[optind], sizeof(cg->name) - 1);
+                       strncpy(cgrp->name, argv[optind], sizeof(cgrp->name) - 1);
                } else {
-                       ret = create_cg(cg_list, cg_list_len);
+                       ret = create_cgrp(cgrp_list, cgrp_list_len);
                        if (ret)
                                goto out;
 
-                       ret = cgroup_copy_cgroup((*cg_list)[(*cg_list_len) - 1],
-                                                (*cg_list)[(*cg_list_len) - 2]);
+                       ret = cgroup_copy_cgroup((*cgrp_list)[(*cgrp_list_len) - 1],
+                                                (*cgrp_list)[(*cgrp_list_len) - 2]);
                        if (ret)
                                goto out;
 
-                       strncpy((*cg_list)[(*cg_list_len) - 1]->name, argv[optind],
-                               sizeof((*cg_list)[(*cg_list_len) - 1]->name) - 1);
+                       strncpy((*cgrp_list)[(*cgrp_list_len) - 1]->name, argv[optind],
+                               sizeof((*cgrp_list)[(*cgrp_list_len) - 1]->name) - 1);
                }
                optind++;
        }
@@ -395,12 +395,12 @@ out:
        return ret;
 }
 
-static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * const cg_list_len,
-                     int * const mode)
+static int parse_opts(int argc, char *argv[], struct cgroup **cgrp_list[],
+                     int * const cgrp_list_len, int * const mode)
 {
        bool do_not_fill_controller = false;
-       bool first_cgroup_is_dummy = false;
-       bool cgroup_mount_type = false;
+       bool first_cgrp_is_dummy = false;
+       bool cgrp_mount_type = false;
        bool fill_controller = false;
        bool print_ctrl_ver = false;
        int ret = 0;
@@ -430,32 +430,32 @@ static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * c
                        break;
                case 'r':
                        do_not_fill_controller = true;
-                       first_cgroup_is_dummy = true;
-                       ret = parse_r_flag(cg_list, cg_list_len, optarg);
+                       first_cgrp_is_dummy = true;
+                       ret = parse_r_flag(cgrp_list, cgrp_list_len, optarg);
                        if (ret)
                                goto err;
                        break;
                case 'g':
                        fill_controller = true;
                        if (strchr(optarg, ':') == NULL) {
-                               first_cgroup_is_dummy = true;
-                               ret = parse_g_flag_no_colon(cg_list, cg_list_len, optarg);
+                               first_cgrp_is_dummy = true;
+                               ret = parse_g_flag_no_colon(cgrp_list, cgrp_list_len, optarg);
                                if (ret)
                                        goto err;
                        } else {
-                               ret = parse_g_flag_with_colon(cg_list, cg_list_len, optarg);
+                               ret = parse_g_flag_with_colon(cgrp_list, cgrp_list_len, optarg);
                                if (ret)
                                        goto err;
                        }
                        break;
                case 'a':
                        fill_controller = true;
-                       ret = parse_a_flag(cg_list, cg_list_len);
+                       ret = parse_a_flag(cgrp_list, cgrp_list_len);
                        if (ret)
                                goto err;
                        break;
                case 'm':
-                       cgroup_mount_type = true;
+                       cgrp_mount_type = true;
                        break;
                case 'c':
                        print_ctrl_ver = true;
@@ -473,13 +473,13 @@ static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * c
        }
 
        /* '-m' and '-c' should not used with other options */
-       if ((cgroup_mount_type || print_ctrl_ver) &&
+       if ((cgrp_mount_type || print_ctrl_ver) &&
            (fill_controller || do_not_fill_controller)) {
                usage(1, argv[0]);
                exit(EXIT_BADARGS);
        }
 
-       if (cgroup_mount_type) {
+       if (cgrp_mount_type) {
                ret = find_cgroup_mount_type();
                if (ret)
                        goto err;
@@ -491,7 +491,7 @@ static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * c
                        goto err;
        }
 
-       ret = parse_opt_args(argc, argv, cg_list, cg_list_len, first_cgroup_is_dummy);
+       ret = parse_opt_args(argc, argv, cgrp_list, cgrp_list_len, first_cgrp_is_dummy);
        if (ret)
                goto err;
 
@@ -499,7 +499,7 @@ err:
        return ret;
 }
 
-static int get_cv_value(struct control_value * const cv, const char * const cg_name,
+static int get_cv_value(struct control_value * const cv, const char * const cgrp_name,
                        const char * const controller_name)
 {
        bool is_multiline = false;
@@ -507,7 +507,7 @@ static int get_cv_value(struct control_value * const cv, const char * const cg_n
        char tmp_line[LL_MAX];
        int ret;
 
-       ret = cgroup_read_value_begin(controller_name, cg_name, cv->name, &handle, tmp_line,
+       ret = cgroup_read_value_begin(controller_name, cgrp_name, cv->name, &handle, tmp_line,
                                      LL_MAX);
        if (ret == ECGEOF)
                goto read_end;
@@ -523,7 +523,7 @@ static int get_cv_value(struct control_value * const cv, const char * const cg_n
                        tmp_ret = cgroup_test_subsys_mounted(controller_name);
                        if (tmp_ret == 0) {
                                err("cgget: cannot find controller '%s' in group '%s'\n",
-                                   controller_name, cg_name);
+                                   controller_name, cgrp_name);
                        } else {
                                err("variable file read failed %s\n", cgroup_strerror(ret));
                        }
@@ -595,7 +595,7 @@ static int indent_multiline_value(struct control_value * const cv)
        return 0;
 }
 
-static int fill_empty_controller(struct cgroup * const cg, struct cgroup_controller * const cgc)
+static int fill_empty_controller(struct cgroup * const cgrp, struct cgroup_controller * const cgc)
 {
        char cgrp_ctrl_path[FILENAME_MAX] = { '\0' };
        char mnt_path[FILENAME_MAX] = { '\0' };
@@ -635,7 +635,7 @@ static int fill_empty_controller(struct cgroup * const cg, struct cgroup_control
         * line:
         * cgget -g cpu:/foo
         */
-       if (cg->name[0] == '/' && cg->name[1] != '\0' &&
+       if (cgrp->name[0] == '/' && cgrp->name[1] != '\0' &&
            strncmp(mnt_path + (mnt_path_len - 7), ".scope/", 7) == 0) {
                snprintf(tmp, FILENAME_MAX, "%s", dirname(mnt_path));
                strncpy(mnt_path, tmp, FILENAME_MAX - 1);
@@ -653,13 +653,13 @@ static int fill_empty_controller(struct cgroup * const cg, struct cgroup_control
                }
        }
 #endif
-       strncat(mnt_path, cg->name, FILENAME_MAX - mnt_path_len - 1);
+       strncat(mnt_path, cgrp->name, FILENAME_MAX - mnt_path_len - 1);
        mnt_path[sizeof(mnt_path) - 1] = '\0';
 
        if (access(mnt_path, F_OK))
                goto out;
 
-       if (!cg_build_path_locked(cg->name, cgrp_ctrl_path, cg_mount_table[i].name))
+       if (!cg_build_path_locked(cgrp->name, cgrp_ctrl_path, cg_mount_table[i].name))
                goto out;
 
        dir = opendir(cgrp_ctrl_path);
@@ -673,7 +673,7 @@ static int fill_empty_controller(struct cgroup * const cg, struct cgroup_control
                if (ctrl_dir->d_type != DT_REG)
                        continue;
 
-               ret = cgroup_fill_cgc(ctrl_dir, cg, cgc, i);
+               ret = cgroup_fill_cgc(ctrl_dir, cgrp, cgc, i);
                if (ret == ECGFAIL)
                        goto out;
 
@@ -702,20 +702,20 @@ out:
        return ret;
 }
 
-static int get_controller_values(struct cgroup * const cg, struct cgroup_controller * const cgc)
+static int get_controller_values(struct cgroup * const cgrp, struct cgroup_controller * const cgc)
 {
        int ret = 0;
        int i;
 
        for (i = 0; i < cgc->index; i++) {
-               ret = get_cv_value(cgc->values[i], cg->name, cgc->name);
+               ret = get_cv_value(cgc->values[i], cgrp->name, cgc->name);
                if (ret)
                        goto out;
        }
 
        if (cgc->index == 0) {
                /* fill the entire controller since no values were provided */
-               ret = fill_empty_controller(cg, cgc);
+               ret = fill_empty_controller(cgrp, cgc);
                if (ret)
                        goto out;
        }
@@ -724,13 +724,13 @@ out:
        return ret;
 }
 
-static int get_cgroup_values(struct cgroup * const cg)
+static int get_cgroup_values(struct cgroup * const cgrp)
 {
        int ret = 0;
        int i;
 
-       for (i = 0; i < cg->index; i++) {
-               ret = get_controller_values(cg, cg->controller[i]);
+       for (i = 0; i < cgrp->index; i++) {
+               ret = get_controller_values(cgrp, cgrp->controller[i]);
                if (ret)
                        break;
        }
@@ -738,13 +738,13 @@ static int get_cgroup_values(struct cgroup * const cg)
        return ret;
 }
 
-static int get_values(struct cgroup *cg_list[], int cg_list_len)
+static int get_values(struct cgroup *cgrp_list[], int cgrp_list_len)
 {
        int ret = 0;
        int i;
 
-       for (i = 0; i < cg_list_len; i++) {
-               ret = get_cgroup_values(cg_list[i]);
+       for (i = 0; i < cgrp_list_len; i++) {
+               ret = get_cgroup_values(cgrp_list[i]);
                if (ret)
                        break;
        }
@@ -796,8 +796,8 @@ static void print_cgroups(struct cgroup *cg_list[], int cg_list_len, int mode)
 int main(int argc, char *argv[])
 {
        int mode = MODE_SHOW_NAMES | MODE_SHOW_HEADERS;
-       struct cgroup **cg_list = NULL;
-       int cg_list_len = 0;
+       struct cgroup **cgrp_list = NULL;
+       int cgrp_list_len = 0;
        int ret = 0, i;
 
        /* No parameter on input? */
@@ -816,7 +816,7 @@ int main(int argc, char *argv[])
        mode |= MODE_SYSTEMD_DELEGATE;
 #endif
 
-       ret = parse_opts(argc, argv, &cg_list, &cg_list_len, &mode);
+       ret = parse_opts(argc, argv, &cgrp_list, &cgrp_list_len, &mode);
        if (ret)
                goto err;
 
@@ -824,15 +824,15 @@ int main(int argc, char *argv[])
        if (mode & MODE_SYSTEMD_DELEGATE)
                cgroup_set_default_systemd_cgroup();
 
-       ret = get_values(cg_list, cg_list_len);
+       ret = get_values(cgrp_list, cgrp_list_len);
        if (ret)
                goto err;
 
-       print_cgroups(cg_list, cg_list_len, mode);
+       print_cgroups(cgrp_list, cgrp_list_len, mode);
 
 err:
-       for (i = 0; i < cg_list_len; i++)
-               cgroup_free(&(cg_list[i]));
+       for (i = 0; i < cgrp_list_len; i++)
+               cgroup_free(&(cgrp_list[i]));
 
        return ret;
 }
index 182e91c7721d4bef1e54f1114049a6088cfeaa91..69c3e5c4bccc069b9799d4ed6f77c2098c86f7fb 100644 (file)
@@ -33,29 +33,29 @@ static char *program_name;
 /* cgroup.subtree_control -r name, value */
 static struct control_value *cgrp_subtree_ctrl_val;
 
-static struct cgroup *copy_name_value_from_cgroup(char src_cg_path[FILENAME_MAX])
+static struct cgroup *copy_name_value_from_cgroup(char src_cgrp_path[FILENAME_MAX])
 {
-       struct cgroup *src_cgroup;
+       struct cgroup *src_cgrp;
        int ret = 0;
 
        /* create source cgroup */
-       src_cgroup = cgroup_new_cgroup(src_cg_path);
-       if (!src_cgroup) {
+       src_cgrp = cgroup_new_cgroup(src_cgrp_path);
+       if (!src_cgrp) {
                err("can't create cgroup: %s\n", cgroup_strerror(ECGFAIL));
-               goto scgroup_err;
+               goto scgrp_err;
        }
 
        /* copy the name-version values to the cgroup structure */
-       ret = cgroup_get_cgroup(src_cgroup);
+       ret = cgroup_get_cgroup(src_cgrp);
        if (ret != 0) {
-               err("cgroup %s error: %s\n", src_cg_path, cgroup_strerror(ret));
-               goto scgroup_err;
+               err("cgroup %s error: %s\n", src_cgrp_path, cgroup_strerror(ret));
+               goto scgrp_err;
        }
 
-       return src_cgroup;
+       return src_cgrp;
 
-scgroup_err:
-       cgroup_free(&src_cgroup);
+scgrp_err:
+       cgroup_free(&src_cgrp);
 
        return NULL;
 }
@@ -452,7 +452,7 @@ int main(int argc, char *argv[])
        int recursive = 0;
        int nv_max = 0;
 
-       char src_cg_path[FILENAME_MAX] = "\0";
+       char src_cgrp_path[FILENAME_MAX] = "\0";
        struct cgroup *subtree_cgrp = NULL;
        struct cgroup *src_cgroup = NULL;
 
@@ -532,8 +532,8 @@ int main(int argc, char *argv[])
                                goto err;
                        }
                        flags |= FL_COPY;
-                       strncpy(src_cg_path, optarg, FILENAME_MAX);
-                       src_cg_path[FILENAME_MAX-1] = '\0';
+                       strncpy(src_cgrp_path, optarg, FILENAME_MAX);
+                       src_cgrp_path[FILENAME_MAX-1] = '\0';
                        break;
                case 'R':
                        recursive = 1;
@@ -587,7 +587,7 @@ int main(int argc, char *argv[])
 
        /* copy the name-value from the given group */
        if ((flags & FL_COPY) != 0) {
-               src_cgroup = copy_name_value_from_cgroup(src_cg_path);
+               src_cgroup = copy_name_value_from_cgroup(src_cgrp_path);
                if (src_cgroup == NULL)
                        goto err;
        }
index 0afad1336ba27a0c5a5850d737cae40e4229627c..d77be0dd254412c9a3ff7980fff4cec00213a969 100644 (file)
@@ -292,12 +292,12 @@ static int display_permissions(const char *path, const char * const cg_name,
  *   controllers records
  * tail
  */
-static int display_cgroup_data(struct cgroup *group,
+static int display_cgroup_data(struct cgroup *cgrp,
                               char controller[CG_CONTROLLER_MAX][FILENAME_MAX],
-                              const char *group_path, int root_path_len, int first,
+                              const char *cgrp_path, int root_path_len, int first,
                               const char *program_name)
 {
-       struct cgroup_controller *group_controller = NULL;
+       struct cgroup_controller *cgrp_controller = NULL;
        char var_path[FILENAME_MAX];
        char *value = NULL;
        char *output_name;
@@ -309,19 +309,19 @@ static int display_cgroup_data(struct cgroup *group,
        char *name;
 
        /* print the  group definition header */
-       fprintf(output_f, "group %s {\n", group->name);
+       fprintf(output_f, "group %s {\n", cgrp->name);
 
        /* for all wanted controllers display controllers tag */
        while (controller[i][0] != '\0') {
                /* display the permission tags */
-               ret = display_permissions(group_path, group->name, controller[i]);
+               ret = display_permissions(cgrp_path, cgrp->name, controller[i]);
                if (ret)
                        return ret;
 
-               group_controller = cgroup_get_controller(group, controller[i]);
-               if (group_controller == NULL) {
+               cgrp_controller = cgroup_get_controller(cgrp, controller[i]);
+               if (cgrp_controller == NULL) {
                        info("cannot find controller '%s' in group '%s'\n", controller[i],
-                            group->name);
+                            cgrp->name);
                        i++;
                        ret = -1;
                        continue;
@@ -333,22 +333,22 @@ static int display_cgroup_data(struct cgroup *group,
                else
                        fprintf(output_f, "\t%s {\n", controller[i]);
                i++;
-               nr_var = cgroup_get_value_name_count(group_controller);
+               nr_var = cgroup_get_value_name_count(cgrp_controller);
 
                for (j = 0; j < nr_var; j++) {
-                       name = cgroup_get_value_name(group_controller, j);
+                       name = cgroup_get_value_name(cgrp_controller, j);
 
                        /*
                         * For the non-root groups cgconfigparser set
                         * permissions of variable files to 777. Thus it
                         * is necessary to test the permissions of variable
-                        * files in the root group to find out whether the
+                        * files in the root cgroup to find out whether the
                         * variable is writable.
                         */
                        if (root_path_len >= FILENAME_MAX)
                                root_path_len = FILENAME_MAX - 1;
 
-                       strncpy(var_path, group_path, root_path_len);
+                       strncpy(var_path, cgrp_path, root_path_len);
                        var_path[root_path_len] = '\0';
 
                        strncat(var_path, "/", FILENAME_MAX - strlen(var_path) - 1);
@@ -416,7 +416,7 @@ static int display_cgroup_data(struct cgroup *group,
                                fprintf(output_f, "\t\tdevices.deny=\"a *:* rwm\";\n");
                        }
 
-                       ret = cgroup_get_value_string(group_controller, name, &value);
+                       ret = cgroup_get_value_string(cgrp_controller, name, &value);
 
                        /* variable can not be read */
                        if (ret != 0) {
@@ -444,9 +444,9 @@ err:
 static int display_controller_data(char controller[CG_CONTROLLER_MAX][FILENAME_MAX],
                                   const char *program_name)
 {
-       char cgroup_name[FILENAME_MAX];
+       char cgrp_name[FILENAME_MAX];
        struct cgroup_file_info info;
-       struct cgroup *group = NULL;
+       struct cgroup *cgrp = NULL;
        int prefix_len;
        void *handle;
        int first = 1;
@@ -468,18 +468,18 @@ static int display_controller_data(char controller[CG_CONTROLLER_MAX][FILENAME_M
                /* some group starts here */
                if (info.type == CGROUP_FILE_TYPE_DIR) {
                        /* parse the group name from full_path*/
-                       strncpy(cgroup_name, &info.full_path[prefix_len], FILENAME_MAX);
-                       cgroup_name[FILENAME_MAX-1] = '\0';
+                       strncpy(cgrp_name, &info.full_path[prefix_len], FILENAME_MAX);
+                       cgrp_name[FILENAME_MAX-1] = '\0';
 
                        /* start to grab data about the new group */
-                       group = cgroup_new_cgroup(cgroup_name);
-                       if (group == NULL) {
-                               info("cannot create group '%s'\n", cgroup_name);
+                       cgrp = cgroup_new_cgroup(cgrp_name);
+                       if (cgrp == NULL) {
+                               info("cannot create cgrp '%s'\n", cgrp_name);
                                ret = ECGFAIL;
                                goto err;
                        }
 
-                       ret = cgroup_get_cgroup(group);
+                       ret = cgroup_get_cgroup(cgrp);
                        if (ret != 0) {
                                /*
                                 * We know for sure that the cgroup exists
@@ -488,17 +488,17 @@ static int display_controller_data(char controller[CG_CONTROLLER_MAX][FILENAME_M
                                 * file.
                                 */
                                if (ret != ECGROUPNOTEXIST) {
-                                       info("cannot read group '%s': %s %d\n", cgroup_name,
+                                       info("cannot read group '%s': %s %d\n", cgrp_name,
                                             cgroup_strerror(ret), ret);
                                        goto err;
                                }
                        }
 
                        if (ret == 0)
-                               display_cgroup_data(group, controller, info.full_path, prefix_len,
+                               display_cgroup_data(cgrp, controller, info.full_path, prefix_len,
                                                    first, program_name);
                        first = 0;
-                       cgroup_free(&group);
+                       cgroup_free(&cgrp);
                }
        }
 
index 2c3039c5b34791b42866f8c1af50ad988eb4e18f..ef69a8a2223e0a50eb8e29d9203a79e67d1fff3c 100644 (file)
@@ -83,24 +83,24 @@ static int get_controller_from_name(const char * const name, char **controller)
        return 0;
 }
 
-static int create_cg(struct cgroup **cg_list[], int * const cg_list_len)
+static int create_cg(struct cgroup **cgrp_list[], int * const cgrp_list_len)
 {
-       *cg_list = realloc(*cg_list, ((*cg_list_len) + 1) * sizeof(struct cgroup *));
-       if ((*cg_list) == NULL)
+       *cgrp_list = realloc(*cgrp_list, ((*cgrp_list_len) + 1) * sizeof(struct cgroup *));
+       if ((*cgrp_list) == NULL)
                return ECGCONTROLLERCREATEFAILED;
 
-       memset(&(*cg_list)[*cg_list_len], 0, sizeof(struct cgroup *));
+       memset(&(*cgrp_list)[*cgrp_list_len], 0, sizeof(struct cgroup *));
 
-       (*cg_list)[*cg_list_len] = cgroup_new_cgroup("");
-       if ((*cg_list)[*cg_list_len] == NULL)
+       (*cgrp_list)[*cgrp_list_len] = cgroup_new_cgroup("");
+       if ((*cgrp_list)[*cgrp_list_len] == NULL)
                return ECGCONTROLLERCREATEFAILED;
 
-       (*cg_list_len)++;
+       (*cgrp_list_len)++;
 
        return 0;
 }
 
-static int parse_a_flag(struct cgroup **cg_list[], int * const cg_list_len)
+static int parse_a_flag(struct cgroup **cgrp_list[], int * const cgrp_list_len)
 {
        struct cgroup_mount_point controller;
        struct cgroup_controller *cgc;
@@ -108,8 +108,8 @@ static int parse_a_flag(struct cgroup **cg_list[], int * const cg_list_len)
        void *handle;
        int ret = 0;
 
-       if ((*cg_list_len) == 0) {
-               ret = create_cg(cg_list, cg_list_len);
+       if ((*cgrp_list_len) == 0) {
+               ret = create_cg(cgrp_list, cgrp_list_len);
                if (ret)
                        goto out;
        }
@@ -119,7 +119,7 @@ static int parse_a_flag(struct cgroup **cg_list[], int * const cg_list_len)
         * an optarg at the end with no flag.  Let's temporarily populate
         * the first cgroup with the requested control values.
         */
-       cg = (*cg_list)[0];
+       cg = (*cgrp_list)[0];
 
        ret = cgroup_get_controller_begin(&handle, &controller);
        while (ret == 0) {
@@ -151,7 +151,7 @@ out:
        return ret;
 }
 
-static int parse_r_flag(struct cgroup **cg_list[], int * const cg_list_len,
+static int parse_r_flag(struct cgroup **cgrp_list[], int * const cgrp_list_len,
                        const char * const cntl_value)
 {
        char *cntl_value_controller = NULL;
@@ -159,8 +159,8 @@ static int parse_r_flag(struct cgroup **cg_list[], int * const cg_list_len,
        struct cgroup *cg = NULL;
        int ret = 0;
 
-       if ((*cg_list_len) == 0) {
-               ret = create_cg(cg_list, cg_list_len);
+       if ((*cgrp_list_len) == 0) {
+               ret = create_cg(cgrp_list, cgrp_list_len);
                if (ret)
                        goto out;
        }
@@ -170,7 +170,7 @@ static int parse_r_flag(struct cgroup **cg_list[], int * const cg_list_len,
         * an optarg at the end with no flag.  Let's temporarily populate
         * the first cgroup with the requested control values.
         */
-       cg = (*cg_list)[0];
+       cg = (*cgrp_list)[0];
 
        ret = get_controller_from_name(cntl_value, &cntl_value_controller);
        if (ret)
@@ -195,20 +195,20 @@ out:
        return ret;
 }
 
-static int parse_g_flag_no_colon(struct cgroup **cg_list[], int * const cg_list_len,
+static int parse_g_flag_no_colon(struct cgroup **cgrp_list[], int * const cgrp_list_len,
                                 const char * const ctrl_str)
 {
        struct cgroup_controller *cgc;
        struct cgroup *cg = NULL;
        int ret = 0;
 
-       if ((*cg_list_len) > 1) {
+       if ((*cgrp_list_len) > 1) {
                ret = ECGMAXVALUESEXCEEDED;
                goto out;
        }
 
-       if ((*cg_list_len) == 0) {
-               ret = create_cg(cg_list, cg_list_len);
+       if ((*cgrp_list_len) == 0) {
+               ret = create_cg(cgrp_list, cgrp_list_len);
                if (ret)
                        goto out;
        }
@@ -219,7 +219,7 @@ static int parse_g_flag_no_colon(struct cgroup **cg_list[], int * const cg_list_
         * Let's temporarily populate the first cgroup with the requested
         * control values.
         */
-       cg = *cg_list[0];
+       cg = *cgrp_list[0];
 
        cgc = cgroup_get_controller(cg, ctrl_str);
        if (!cgc) {
@@ -234,18 +234,18 @@ out:
        return ret;
 }
 
-static int split_cgroup_name(const char * const ctrl_str, char *cg_name)
+static int split_cgroup_name(const char * const ctrl_str, char *cgrp_name)
 {
        char *colon;
 
        colon = strchr(ctrl_str, ':');
        if (colon == NULL) {
                /* ctrl_str doesn't contain a ":" */
-               cg_name[0] = '\0';
+               cgrp_name[0] = '\0';
                return ECGINVAL;
        }
 
-       strncpy(cg_name, &colon[1], FILENAME_MAX - 1);
+       strncpy(cgrp_name, &colon[1], FILENAME_MAX - 1);
 
        return 0;
 }
@@ -289,7 +289,7 @@ out:
        return ret;
 }
 
-static int parse_g_flag_with_colon(struct cgroup **cg_list[], int * const cg_list_len,
+static int parse_g_flag_with_colon(struct cgroup **cgrp_list[], int * const cgrp_list_len,
                                   const char * const ctrl_str)
 {
        struct cgroup_controller *cgc;
@@ -298,11 +298,11 @@ static int parse_g_flag_with_colon(struct cgroup **cg_list[], int * const cg_lis
        int controllers_len = 0;
        int i, ret = 0;
 
-       ret = create_cg(cg_list, cg_list_len);
+       ret = create_cg(cgrp_list, cgrp_list_len);
        if (ret)
                goto out;
 
-       cg = (*cg_list)[(*cg_list_len) - 1];
+       cg = (*cgrp_list)[(*cgrp_list_len) - 1];
 
        ret = split_cgroup_name(ctrl_str, cg->name);
        if (ret)
@@ -330,8 +330,8 @@ out:
        return ret;
 }
 
-static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[],
-                         int * const cg_list_len, bool first_cg_is_dummy)
+static int parse_opt_args(int argc, char *argv[], struct cgroup **cgrp_list[],
+                         int * const cgrp_list_len, bool first_cgrp_is_dummy)
 {
        struct cgroup *cg = NULL;
        int ret = 0;
@@ -340,7 +340,7 @@ static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[],
         * The first cgroup was temporarily populated and requires the
         * user to provide a cgroup name as an opt
         */
-       if (argv[optind] == NULL && first_cg_is_dummy) {
+       if (argv[optind] == NULL && first_cgrp_is_dummy) {
                usage(1, argv[0]);
                exit(EXIT_BADARGS);
        }
@@ -354,30 +354,31 @@ static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[],
         * Example of a command that will hit this code:
         *      $ cgxget -g cpu:mycgroup mycgroup
         */
-       if (argv[optind] != NULL && (*cg_list_len) > 0 && strcmp((*cg_list)[0]->name, "") != 0) {
+       if (argv[optind] != NULL && (*cgrp_list_len) > 0 &&
+           strcmp((*cgrp_list)[0]->name, "") != 0) {
                usage(1, argv[0]);
                exit(EXIT_BADARGS);
        }
 
        while (argv[optind] != NULL) {
-               if ((*cg_list_len) > 0)
-                       cg = (*cg_list)[(*cg_list_len) - 1];
+               if ((*cgrp_list_len) > 0)
+                       cg = (*cgrp_list)[(*cgrp_list_len) - 1];
                else
                        cg = NULL;
 
-               if ((*cg_list_len) == 0) {
+               if ((*cgrp_list_len) == 0) {
                        /*
                         * The user didn't provide a '-r' or '-g' flag.
                         * The parse_a_flag() function can be reused here
                         * because we both have the same use case - gather
                         * all the data about this particular cgroup.
                         */
-                       ret = parse_a_flag(cg_list, cg_list_len);
+                       ret = parse_a_flag(cgrp_list, cgrp_list_len);
                        if (ret)
                                goto out;
 
-                       strncpy((*cg_list)[(*cg_list_len) - 1]->name, argv[optind],
-                               sizeof((*cg_list)[(*cg_list_len) - 1]->name) - 1);
+                       strncpy((*cgrp_list)[(*cgrp_list_len) - 1]->name, argv[optind],
+                               sizeof((*cgrp_list)[(*cgrp_list_len) - 1]->name) - 1);
                } else if (cg != NULL && strlen(cg->name) == 0) {
                        /*
                         * this cgroup was created based upon control/value
@@ -386,17 +387,17 @@ static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[],
                         */
                        strncpy(cg->name, argv[optind], sizeof(cg->name) - 1);
                } else {
-                       ret = create_cg(cg_list, cg_list_len);
+                       ret = create_cg(cgrp_list, cgrp_list_len);
                        if (ret)
                                goto out;
 
-                       ret = cgroup_copy_cgroup((*cg_list)[(*cg_list_len) - 1],
-                                                (*cg_list)[(*cg_list_len) - 2]);
+                       ret = cgroup_copy_cgroup((*cgrp_list)[(*cgrp_list_len) - 1],
+                                                (*cgrp_list)[(*cgrp_list_len) - 2]);
                        if (ret)
                                goto out;
 
-                       strncpy((*cg_list)[(*cg_list_len) - 1]->name, argv[optind],
-                               sizeof((*cg_list)[(*cg_list_len) - 1]->name) - 1);
+                       strncpy((*cgrp_list)[(*cgrp_list_len) - 1]->name, argv[optind],
+                               sizeof((*cgrp_list)[(*cgrp_list_len) - 1]->name) - 1);
                }
 
                optind++;
@@ -406,9 +407,9 @@ out:
        return ret;
 }
 
-static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * const cg_list_len,
-                     int * const mode, enum cg_version_t * const version,
-                     bool * const ignore_unmappable)
+static int parse_opts(int argc, char *argv[], struct cgroup **cgrp_list[],
+                     int * const cgrp_list_len, int * const mode,
+                     enum cg_version_t * const version, bool * const ignore_unmappable)
 {
        bool do_not_fill_controller = false;
        bool first_cgroup_is_dummy = false;
@@ -441,7 +442,7 @@ static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * c
                case 'r':
                        do_not_fill_controller = true;
                        first_cgroup_is_dummy = true;
-                       ret = parse_r_flag(cg_list, cg_list_len, optarg);
+                       ret = parse_r_flag(cgrp_list, cgrp_list_len, optarg);
                        if (ret)
                                goto err;
                        break;
@@ -449,18 +450,18 @@ static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * c
                        fill_controller = true;
                        if (strchr(optarg, ':') == NULL) {
                                first_cgroup_is_dummy = true;
-                               ret = parse_g_flag_no_colon(cg_list, cg_list_len, optarg);
+                               ret = parse_g_flag_no_colon(cgrp_list, cgrp_list_len, optarg);
                                if (ret)
                                        goto err;
                        } else {
-                               ret = parse_g_flag_with_colon(cg_list, cg_list_len, optarg);
+                               ret = parse_g_flag_with_colon(cgrp_list, cgrp_list_len, optarg);
                                if (ret)
                                        goto err;
                        }
                        break;
                case 'a':
                        fill_controller = true;
-                       ret = parse_a_flag(cg_list, cg_list_len);
+                       ret = parse_a_flag(cgrp_list, cgrp_list_len);
                        if (ret)
                                goto err;
                        break;
@@ -485,7 +486,7 @@ static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * c
                exit(EXIT_BADARGS);
        }
 
-       ret = parse_opt_args(argc, argv, cg_list, cg_list_len, first_cgroup_is_dummy);
+       ret = parse_opt_args(argc, argv, cgrp_list, cgrp_list_len, first_cgroup_is_dummy);
        if (ret)
                goto err;
 
@@ -494,7 +495,7 @@ err:
 }
 #endif /* !LIBCG_LIB */
 
-static int get_cv_value(struct control_value * const cv, const char * const cg_name,
+static int get_cv_value(struct control_value * const cv, const char * const cgrp_name,
                        const char * const controller_name)
 {
        bool is_multiline = false;
@@ -502,7 +503,7 @@ static int get_cv_value(struct control_value * const cv, const char * const cg_n
        void *handle, *tmp;
        int ret;
 
-       ret = cgroup_read_value_begin(controller_name, cg_name, cv->name, &handle, tmp_line,
+       ret = cgroup_read_value_begin(controller_name, cgrp_name, cv->name, &handle, tmp_line,
                                      LL_MAX);
        if (ret == ECGEOF)
                goto read_end;
@@ -518,7 +519,7 @@ static int get_cv_value(struct control_value * const cv, const char * const cg_n
                        tmp_ret = cgroup_test_subsys_mounted(controller_name);
                        if (tmp_ret == 0) {
                                err("cgxget: cannot find controller '%s' in group '%s'\n",
-                                   controller_name, cg_name);
+                                   controller_name, cgrp_name);
                        } else {
                                err("variable file read failed %s\n", cgroup_strerror(ret));
                        }
@@ -733,13 +734,13 @@ static int get_cgroup_values(struct cgroup * const cg)
 }
 
 #ifndef LIBCG_LIB
-static int get_values(struct cgroup *cg_list[], int cg_list_len)
+static int get_values(struct cgroup *cgrp_list[], int cgrp_list_len)
 {
        int ret = 0;
        int i;
 
-       for (i = 0; i < cg_list_len; i++) {
-               ret = get_cgroup_values(cg_list[i]);
+       for (i = 0; i < cgrp_list_len; i++) {
+               ret = get_cgroup_values(cgrp_list[i]);
                if (ret)
                        break;
        }
@@ -780,32 +781,32 @@ static void print_cgroup(const struct cgroup * const cg, int mode)
                info("\n");
 }
 
-static void print_cgroups(struct cgroup *cg_list[], int cg_list_len, int mode)
+static void print_cgroups(struct cgroup *cgrp_list[], int cgrp_list_len, int mode)
 {
        int i;
 
-       for (i = 0; i < cg_list_len; i++)
-               print_cgroup(cg_list[i], mode);
+       for (i = 0; i < cgrp_list_len; i++)
+               print_cgroup(cgrp_list[i], mode);
 }
 
-static int convert_cgroups(struct cgroup **cg_list[], int cg_list_len,
+static int convert_cgroups(struct cgroup **cgrp_list[], int cgrp_list_len,
                           enum cg_version_t in_version, enum cg_version_t out_version)
 {
-       struct cgroup **cg_converted_list;
+       struct cgroup **cgrp_converted_list;
        int i = 0, j, ret = 0;
 
-       cg_converted_list = malloc(cg_list_len * sizeof(struct cgroup *));
-       if (cg_converted_list == NULL)
+       cgrp_converted_list = malloc(cgrp_list_len * sizeof(struct cgroup *));
+       if (cgrp_converted_list == NULL)
                goto out;
 
-       for (i = 0; i < cg_list_len; i++) {
-               cg_converted_list[i] = cgroup_new_cgroup((*cg_list)[i]->name);
-               if (cg_converted_list[i] == NULL) {
+       for (i = 0; i < cgrp_list_len; i++) {
+               cgrp_converted_list[i] = cgroup_new_cgroup((*cgrp_list)[i]->name);
+               if (cgrp_converted_list[i] == NULL) {
                        ret = ECGCONTROLLERCREATEFAILED;
                        goto out;
                }
 
-               ret = cgroup_convert_cgroup(cg_converted_list[i], out_version, (*cg_list)[i],
+               ret = cgroup_convert_cgroup(cgrp_converted_list[i], out_version, (*cgrp_list)[i],
                                            in_version);
                if (ret)
                        goto out;
@@ -815,17 +816,17 @@ out:
        if (ret != 0 && ret != ECGNOVERSIONCONVERT) {
                /* The conversion failed */
                for (j = 0; j < i; j++)
-                       cgroup_free(&(cg_converted_list[j]));
-               free(cg_converted_list);
+                       cgroup_free(&(cgrp_converted_list[j]));
+               free(cgrp_converted_list);
        } else {
                /*
                 * The conversion succeeded or was unmappable.
                 * Free the old list.
                 */
-               for (i = 0; i < cg_list_len; i++)
-                       cgroup_free(&(*cg_list)[i]);
+               for (i = 0; i < cgrp_list_len; i++)
+                       cgroup_free(&(*cgrp_list)[i]);
 
-               *cg_list = cg_converted_list;
+               *cgrp_list = cgrp_converted_list;
        }
 
        return ret;
@@ -835,9 +836,9 @@ int main(int argc, char *argv[])
 {
        int mode = MODE_SHOW_NAMES | MODE_SHOW_HEADERS;
        enum cg_version_t version = CGROUP_UNK;
-       struct cgroup **cg_list = NULL;
+       struct cgroup **cgrp_list = NULL;
        bool ignore_unmappable = false;
-       int cg_list_len = 0;
+       int cgrp_list_len = 0;
        int ret = 0, i;
 
        /* No parameter on input? */
@@ -856,7 +857,8 @@ int main(int argc, char *argv[])
        mode |= MODE_SYSTEMD_DELEGATE;
 #endif
 
-       ret = parse_opts(argc, argv, &cg_list, &cg_list_len, &mode, &version, &ignore_unmappable);
+       ret = parse_opts(argc, argv, &cgrp_list, &cgrp_list_len, &mode, &version,
+                        &ignore_unmappable);
        if (ret)
                goto err;
 
@@ -864,7 +866,7 @@ int main(int argc, char *argv[])
        if (mode & MODE_SYSTEMD_DELEGATE)
                cgroup_set_default_systemd_cgroup();
 
-       ret = convert_cgroups(&cg_list, cg_list_len, version, CGROUP_DISK);
+       ret = convert_cgroups(&cgrp_list, cgrp_list_len, version, CGROUP_DISK);
        if ((ret && ret != ECGNOVERSIONCONVERT) ||
            (ret == ECGNOVERSIONCONVERT && !ignore_unmappable))
                /*
@@ -874,19 +876,19 @@ int main(int argc, char *argv[])
                 */
                goto err;
 
-       ret = get_values(cg_list, cg_list_len);
+       ret = get_values(cgrp_list, cgrp_list_len);
        if (ret)
                goto err;
 
-       ret = convert_cgroups(&cg_list, cg_list_len, CGROUP_DISK, version);
+       ret = convert_cgroups(&cgrp_list, cgrp_list_len, CGROUP_DISK, version);
        if (ret)
                goto err;
 
-       print_cgroups(cg_list, cg_list_len, mode);
+       print_cgroups(cgrp_list, cgrp_list_len, mode);
 
 err:
-       for (i = 0; i < cg_list_len; i++)
-               cgroup_free(&(cg_list[i]));
+       for (i = 0; i < cgrp_list_len; i++)
+               cgroup_free(&(cgrp_list[i]));
 
        return ret;
 }
index 52bc3999c161ac8fc1af5f65176d8126a69012ef..2fc841a77d5b4e3f184c924d443dae9ebf60a3a5 100644 (file)
@@ -43,29 +43,29 @@ static char *program_name;
 /* cgroup.subtree_control -r name, value */
 static struct control_value *cgrp_subtree_ctrl_val;
 
-static struct cgroup *copy_name_value_from_cgroup(char src_cg_path[FILENAME_MAX])
+static struct cgroup *copy_name_value_from_cgroup(char src_cgrp_path[FILENAME_MAX])
 {
-       struct cgroup *src_cgroup;
+       struct cgroup *src_cgrp;
        int ret = 0;
 
        /* create source cgroup */
-       src_cgroup = cgroup_new_cgroup(src_cg_path);
-       if (!src_cgroup) {
+       src_cgrp = cgroup_new_cgroup(src_cgrp_path);
+       if (!src_cgrp) {
                err("can't create cgroup: %s\n", cgroup_strerror(ECGFAIL));
-               goto scgroup_err;
+               goto scgrp_err;
        }
 
        /* copy the name-version values to the cgroup structure */
-       ret = cgroup_get_cgroup(src_cgroup);
+       ret = cgroup_get_cgroup(src_cgrp);
        if (ret != 0) {
-               err("cgroup %s error: %s\n", src_cg_path, cgroup_strerror(ret));
-               goto scgroup_err;
+               err("cgroup %s error: %s\n", src_cgrp_path, cgroup_strerror(ret));
+               goto scgrp_err;
        }
 
-       return src_cgroup;
+       return src_cgrp;
 
-scgroup_err:
-       cgroup_free(&src_cgroup);
+scgrp_err:
+       cgroup_free(&src_cgrp);
 
        return NULL;
 }
@@ -119,7 +119,7 @@ static int cgroup_set_cgroup_values(struct cgroup *src_cgrp, const char * const
 
        /*
         * If a failure occurs between this comment and the "End of above comment"
-        * below, then we need to manually free converted_src_cgroup.
+        * below, then we need to manually free converted_src_cgrp.
         */
 
        ret = cgroup_convert_cgroup(converted_src_cgrp, CGROUP_DISK, src_cgrp, src_version);
@@ -135,7 +135,7 @@ static int cgroup_set_cgroup_values(struct cgroup *src_cgrp, const char * const
        }
 
        /*
-        * End of above comment about converted_src_cgroup needing to be manually freed.
+        * End of above comment about converted_src_cgrp needing to be manually freed.
         */
        cgroup_free(&cgrp);
        cgrp = converted_src_cgrp;
@@ -506,9 +506,9 @@ int main(int argc, char *argv[])
        int recursive = 0;
        int nv_max = 0;
 
-       char src_cg_path[FILENAME_MAX] = "\0";
+       char src_cgrp_path[FILENAME_MAX] = "\0";
        struct cgroup *subtree_cgrp = NULL;
-       struct cgroup *src_cgroup = NULL;
+       struct cgroup *src_cgrp = NULL;
 
        enum cg_version_t src_version = CGROUP_UNK;
        bool ignore_unmappable = false;
@@ -587,8 +587,8 @@ int main(int argc, char *argv[])
                                goto err;
                        }
                        flags |= FL_COPY;
-                       strncpy(src_cg_path, optarg, FILENAME_MAX);
-                       src_cg_path[FILENAME_MAX-1] = '\0';
+                       strncpy(src_cgrp_path, optarg, FILENAME_MAX);
+                       src_cgrp_path[FILENAME_MAX-1] = '\0';
                        break;
                case '1':
                        src_version = CGROUP_V1;
@@ -637,8 +637,8 @@ int main(int argc, char *argv[])
 
        /* copy the name-value pairs from -r options */
        if ((flags & FL_RULES) != 0) {
-               src_cgroup = create_cgroup_from_name_value_pairs("tmp", name_value, nv_number);
-               if (src_cgroup == NULL)
+               src_cgrp = create_cgroup_from_name_value_pairs("tmp", name_value, nv_number);
+               if (src_cgrp == NULL)
                        goto err;
 
                if (cgrp_subtree_ctrl_val && !recursive) {
@@ -651,22 +651,22 @@ int main(int argc, char *argv[])
 
        /* copy the name-value from the given group */
        if ((flags & FL_COPY) != 0) {
-               src_cgroup = copy_name_value_from_cgroup(src_cg_path);
-               if (src_cgroup == NULL)
+               src_cgrp = copy_name_value_from_cgroup(src_cgrp_path);
+               if (src_cgrp == NULL)
                        goto err;
        }
 
        while (optind < argc) {
 
                if (recursive) {
-                       ret = cgroup_set_cgroup_values_r(src_cgroup, argv[optind],
+                       ret = cgroup_set_cgroup_values_r(src_cgrp, argv[optind],
                                                         ignore_unmappable, src_version);
                } else {
                        ret = cgroup_set_cgroup_values(subtree_cgrp, argv[optind],
                                                       ignore_unmappable, src_version);
                        if (ret)
                                goto err;
-                       ret = cgroup_set_cgroup_values(src_cgroup, argv[optind],
+                       ret = cgroup_set_cgroup_values(src_cgrp, argv[optind],
                                                       ignore_unmappable, src_version);
                }
                if (ret)
@@ -676,7 +676,7 @@ int main(int argc, char *argv[])
        }
 
 err:
-       cgroup_free(&src_cgroup);
+       cgroup_free(&src_cgrp);
        cgroup_free(&subtree_cgrp);
        free(name_value);
 
index eb7d1c56d7abe074acedaf2cc3efbc42c9eb4b34..bf24ae8d7c1d4ccec094d4dacee200f8c80903e1 100644 (file)
@@ -57,12 +57,12 @@ static void usage(int status, const char *program_name)
  * if the info about controller "name" should be printed, then the function
  * returns nonzero value
  */
-static int is_ctlr_on_list(struct cgroup_group_spec *cgroup_list, const char *name)
+static int is_ctlr_on_list(struct cgroup_group_spec *cgrp_list, const char *name)
 {
        int j;
 
-       for (j = 0; cgroup_list->controllers[j] != NULL; j++)
-               if (strcmp(cgroup_list->controllers[j], name) == 0)
+       for (j = 0; cgrp_list->controllers[j] != NULL; j++)
+               if (strcmp(cgrp_list->controllers[j], name) == 0)
                        return 1;
 
        return 0;
@@ -81,8 +81,8 @@ static void print_info(struct cgroup_file_info *info, char *name, int pref)
 /* display controller:/input_path cgroups */
 static int display_controller_data(char *input_path, char *controller, char *name)
 {
-       char cgroup_dir_path[FILENAME_MAX];
        char input_dir_path[FILENAME_MAX];
+       char cgrp_dir_path[FILENAME_MAX];
        struct cgroup_file_info info;
        int lvl, len, ret;
        void *handle;
@@ -91,17 +91,17 @@ static int display_controller_data(char *input_path, char *controller, char *nam
        if (ret != 0)
                return ret;
 
-       strncpy(cgroup_dir_path, info.full_path, FILENAME_MAX);
-       cgroup_dir_path[sizeof(cgroup_dir_path) - 1] = '\0';
+       strncpy(cgrp_dir_path, info.full_path, FILENAME_MAX);
+       cgrp_dir_path[sizeof(cgrp_dir_path) - 1] = '\0';
        /* remove problematic  '/' characters from cgroup directory path */
-       trim_filepath(cgroup_dir_path);
+       trim_filepath(cgrp_dir_path);
 
        strncpy(input_dir_path, input_path, FILENAME_MAX);
        input_dir_path[sizeof(input_dir_path) - 1] = '\0';
 
        /* remove problematic  '/' characters from input directory path */
        trim_filepath(input_dir_path);
-       len  = strlen(cgroup_dir_path) - strlen(input_dir_path);
+       len  = strlen(cgrp_dir_path) - strlen(input_dir_path);
        print_info(&info, name, len);
 
        while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) == 0)
@@ -118,7 +118,7 @@ static int display_controller_data(char *input_path, char *controller, char *nam
  * print data about input cgroup_list cgroups if FL_LIST flag is set then
  * if the function does not find the cgroup it returns ECGEOF
  */
-static int print_cgroup(struct cgroup_group_spec *cgroup_spec, int flags)
+static int print_cgroup(struct cgroup_group_spec *cgrp_spec, int flags)
 {
        struct cgroup_mount_point controller;
        char all_conts[FILENAME_MAX];
@@ -144,8 +144,7 @@ static int print_cgroup(struct cgroup_group_spec *cgroup_spec, int flags)
                } else {
                        /* we got new mount point, print it if needed */
                        if (output) {
-                               ret = display_controller_data(cgroup_spec->path, con_name,
-                                                             all_conts);
+                               ret = display_controller_data(cgrp_spec->path, con_name, all_conts);
                                if (ret)
                                        return ret;
                                if ((flags & FL_LIST) != 0) {
@@ -168,7 +167,7 @@ static int print_cgroup(struct cgroup_group_spec *cgroup_spec, int flags)
 
                /* set output flag */
                if ((output == 0) && (!(flags & FL_LIST) ||
-                   (is_ctlr_on_list(cgroup_spec, controller.name))))
+                   (is_ctlr_on_list(cgrp_spec, controller.name))))
                        output = 1;
 
                /* the actual controller should not be printed */
@@ -180,13 +179,13 @@ static int print_cgroup(struct cgroup_group_spec *cgroup_spec, int flags)
                return ret;
 
        if (output)
-               ret = display_controller_data(cgroup_spec->path, con_name, all_conts);
+               ret = display_controller_data(cgrp_spec->path, con_name, all_conts);
 
        return ret;
 }
 
 
-static int cgroup_list_cgroups(char *tname, struct cgroup_group_spec *cgroup_list[], int flags)
+static int cgroup_list_cgroups(char *tname, struct cgroup_group_spec *cgrp_list[], int flags)
 {
        int final_ret = 0;
        int ret = 0;
@@ -200,12 +199,12 @@ static int cgroup_list_cgroups(char *tname, struct cgroup_group_spec *cgroup_lis
        }
 
        if ((flags & FL_LIST) == 0) {
-               struct cgroup_group_spec *cgroup_spec;
+               struct cgroup_group_spec *cgrp_spec;
 
-               cgroup_spec = calloc(1, sizeof(struct cgroup_group_spec));
+               cgrp_spec = calloc(1, sizeof(struct cgroup_group_spec));
                /* we have to print all cgroups */
-               ret = print_cgroup(cgroup_spec,  flags);
-               free(cgroup_spec);
+               ret = print_cgroup(cgrp_spec,  flags);
+               free(cgrp_spec);
                if (ret == 0) {
                        final_ret = 0;
                } else {
@@ -214,9 +213,9 @@ static int cgroup_list_cgroups(char *tname, struct cgroup_group_spec *cgroup_lis
                }
        } else {
                /* we have he list of controllers which should be print */
-               while ((cgroup_list[i] != NULL) && ((ret == ECGEOF) || (ret == 0))) {
+               while ((cgrp_list[i] != NULL)   && ((ret == ECGEOF) || (ret == 0))) {
 
-                       ret = print_cgroup(cgroup_list[i], flags);
+                       ret = print_cgroup(cgrp_list[i], flags);
                        if (ret != 0) {
                                if (ret == ECGEOF) {
                                        /* controller was not found */
@@ -227,7 +226,7 @@ static int cgroup_list_cgroups(char *tname, struct cgroup_group_spec *cgroup_lis
                                }
 
                                err("%s: cannot find group %s..:%s: %s\n", tname,
-                                   cgroup_list[i]->controllers[0], cgroup_list[i]->path,
+                                   cgrp_list[i]->controllers[0], cgrp_list[i]->path,
                                    cgroup_strerror(final_ret));
                        }
                        i++;
@@ -245,7 +244,7 @@ int main(int argc, char *argv[])
                {0, 0, 0, 0}
        };
 
-       struct cgroup_group_spec *cgroup_list[CG_HIER_MAX];
+       struct cgroup_group_spec *cgrp_list[CG_HIER_MAX];
 #ifdef WITH_SYSTEMD
        int ignore_default_systemd_delegate_slice = 0;
 #endif
@@ -254,7 +253,7 @@ int main(int argc, char *argv[])
        int c;
        int i;
 
-       memset(cgroup_list, 0, sizeof(cgroup_list));
+       memset(cgrp_list, 0, sizeof(cgrp_list));
 
        /* parse arguments */
 #ifdef WITH_SYSTEMD
@@ -272,7 +271,7 @@ int main(int argc, char *argv[])
                        ret = 0;
                        goto err;
                case 'g':
-                       ret = parse_cgroup_spec(cgroup_list, optarg, CG_HIER_MAX);
+                       ret = parse_cgroup_spec(cgrp_list, optarg, CG_HIER_MAX);
                        if (ret) {
                                err("%s: cgroup controller and path parsing failed (%s)\n",
                                    argv[0], optarg);
@@ -300,7 +299,7 @@ int main(int argc, char *argv[])
 
        /* read the list of controllers */
        while (optind < argc) {
-               ret = parse_cgroup_spec(cgroup_list, argv[optind], CG_HIER_MAX);
+               ret = parse_cgroup_spec(cgrp_list, argv[optind], CG_HIER_MAX);
                if (ret) {
                        err("%s: cgroup controller an path parsing failed (%s)\n", argv[0],
                            argv[optind]);
@@ -309,19 +308,19 @@ int main(int argc, char *argv[])
                optind++;
        }
 
-       if (cgroup_list[0] != NULL) {
+       if (cgrp_list[0] != NULL) {
                /* cgroups on input */
                flags |= FL_LIST;
        }
 
        /* print the information based on list of input cgroups and flags */
-       ret = cgroup_list_cgroups(argv[0], cgroup_list, flags);
+       ret = cgroup_list_cgroups(argv[0], cgrp_list, flags);
 
 err:
-       if (cgroup_list[0]) {
+       if (cgrp_list[0]) {
                for (i = 0; i < CG_HIER_MAX; i++) {
-                       if (cgroup_list[i])
-                               cgroup_free_group_spec(cgroup_list[i]);
+                       if (cgrp_list[i])
+                               cgroup_free_group_spec(cgrp_list[i]);
                }
        }