From: Kamalesh Babulal Date: Mon, 14 Oct 2024 01:17:03 +0000 (+0530) Subject: samples/c: match naming with upstream Linux X-Git-Tag: v3.2.0~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c72a703bac6fe123d163a66b9545eeb992fbe8be;p=thirdparty%2Flibcgroup.git samples/c: match naming with upstream Linux Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel, across the files under samples/c/ bringing it closer to the Linux kernel cgroup code. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/samples/c/create_systemd_scope.c b/samples/c/create_systemd_scope.c index 4d14ea84..e4843f54 100644 --- a/samples/c/create_systemd_scope.c +++ b/samples/c/create_systemd_scope.c @@ -184,16 +184,16 @@ error: static int create_tmp_cgroup(const struct example_opts * const opts) { - struct cgroup *cg; + struct cgroup *cgrp; int ret = 0; - cg = cgroup_new_cgroup(TMP_CGNAME); - if (!cg) { + cgrp = cgroup_new_cgroup(TMP_CGNAME); + if (!cgrp) { printf("Failed to allocate the cgroup struct. Are we out of memory?\n"); goto error; } - ret = cgroup_create_cgroup(cg, 1); + ret = cgroup_create_cgroup(cgrp, 1); if (ret) { printf("Failed to write the cgroup to /sys/fs/cgroup: %d: %s\n", ret, cgroup_strerror(ret)); @@ -201,15 +201,15 @@ static int create_tmp_cgroup(const struct example_opts * const opts) } error: - if (cg) - cgroup_free(&cg); + if (cgrp) + cgroup_free(&cgrp); return ret; } static int move_pids_to_tmp_cgroup(const struct example_opts * const opts) { - struct cgroup *cg = NULL; + struct cgroup *cgrp = NULL; int ret, pid_cnt, i; pid_t *pids = NULL; int saved_ret = 0; @@ -227,14 +227,14 @@ static int move_pids_to_tmp_cgroup(const struct example_opts * const opts) goto error; } - cg = cgroup_new_cgroup(TMP_CGNAME); - if (!cg) { + cgrp = cgroup_new_cgroup(TMP_CGNAME); + if (!cgrp) { printf("Failed to allocate the cgroup struct. Are we out of memory?\n"); goto error; } for (i = 0; i < pid_cnt; i++) { - ret = cgroup_attach_task_pid(cg, pids[i]); + ret = cgroup_attach_task_pid(cgrp, pids[i]); if (ret) { printf("Failed to attach pid %d to %s\n", pids[i], TMP_CGNAME); /* @@ -251,8 +251,8 @@ error: if (pids) free(pids); - if (cg) - cgroup_free(&cg); + if (cgrp) + cgroup_free(&cgrp); if (ret == 0 && saved_ret) ret = saved_ret; @@ -263,20 +263,19 @@ error: static int create_high_priority_cgroup(const struct example_opts * const opts) { struct cgroup_controller *ctrl; - struct cgroup *cg; + struct cgroup *cgrp; int ret = 0; - cg = cgroup_new_cgroup(HIGH_CGNAME); - if (!cg) { + cgrp = cgroup_new_cgroup(HIGH_CGNAME); + if (!cgrp) { printf("Failed to allocate the cgroup struct. Are we out of memory?\n"); ret = ECGFAIL; goto error; } - ctrl = cgroup_add_controller(cg, "cpu"); + ctrl = cgroup_add_controller(cgrp, "cpu"); if (!ctrl) { - printf("Failed to add the cpu controller to the %s cgroup struct\n", - HIGH_CGNAME); + printf("Failed to add the cpu controller to the %s cgroup struct\n", HIGH_CGNAME); ret = ECGFAIL; goto error; } @@ -288,7 +287,7 @@ static int create_high_priority_cgroup(const struct example_opts * const opts) goto error; } - ctrl = cgroup_add_controller(cg, "memory"); + ctrl = cgroup_add_controller(cgrp, "memory"); if (!ctrl) { printf("Failed to add the memory controller to the %s cgroup struct\n", HIGH_CGNAME); @@ -303,7 +302,7 @@ static int create_high_priority_cgroup(const struct example_opts * const opts) goto error; } - ret = cgroup_create_cgroup(cg, 0); + ret = cgroup_create_cgroup(cgrp, 0); if (ret) { printf("Failed to write the %s cgroup to /sys/fs/cgroup: %d: %s\n", HIGH_CGNAME, ret, cgroup_strerror(ret)); @@ -311,8 +310,8 @@ static int create_high_priority_cgroup(const struct example_opts * const opts) } error: - if (cg) - cgroup_free(&cg); + if (cgrp) + cgroup_free(&cgrp); return ret; } @@ -320,20 +319,19 @@ error: static int create_medium_priority_cgroup(const struct example_opts * const opts) { struct cgroup_controller *ctrl; - struct cgroup *cg; + struct cgroup *cgrp; int ret = 0; - cg = cgroup_new_cgroup(MED_CGNAME); - if (!cg) { + cgrp = cgroup_new_cgroup(MED_CGNAME); + if (!cgrp) { printf("Failed to allocate the cgroup struct. Are we out of memory?\n"); ret = ECGFAIL; goto error; } - ctrl = cgroup_add_controller(cg, "cpu"); + ctrl = cgroup_add_controller(cgrp, "cpu"); if (!ctrl) { - printf("Failed to add the cpu controller to the %s cgroup struct\n", - MED_CGNAME); + printf("Failed to add the cpu controller to the %s cgroup struct\n", MED_CGNAME); ret = ECGFAIL; goto error; } @@ -345,7 +343,7 @@ static int create_medium_priority_cgroup(const struct example_opts * const opts) goto error; } - ctrl = cgroup_add_controller(cg, "memory"); + ctrl = cgroup_add_controller(cgrp, "memory"); if (!ctrl) { printf("Failed to add the memory controller to the %s cgroup struct\n", MED_CGNAME); @@ -360,7 +358,7 @@ static int create_medium_priority_cgroup(const struct example_opts * const opts) goto error; } - ret = cgroup_create_cgroup(cg, 0); + ret = cgroup_create_cgroup(cgrp, 0); if (ret) { printf("Failed to write the %s cgroup to /sys/fs/cgroup: %d: %s\n", MED_CGNAME, ret, cgroup_strerror(ret)); @@ -368,8 +366,8 @@ static int create_medium_priority_cgroup(const struct example_opts * const opts) } error: - if (cg) - cgroup_free(&cg); + if (cgrp) + cgroup_free(&cgrp); return ret; } @@ -377,20 +375,19 @@ error: static int create_low_priority_cgroup(const struct example_opts * const opts) { struct cgroup_controller *ctrl; - struct cgroup *cg; + struct cgroup *cgrp; int ret = 0; - cg = cgroup_new_cgroup(LOW_CGNAME); - if (!cg) { + cgrp = cgroup_new_cgroup(LOW_CGNAME); + if (!cgrp) { printf("Failed to allocate the cgroup struct. Are we out of memory?\n"); ret = ECGFAIL; goto error; } - ctrl = cgroup_add_controller(cg, "cpu"); + ctrl = cgroup_add_controller(cgrp, "cpu"); if (!ctrl) { - printf("Failed to add the cpu controller to the %s cgroup struct\n", - LOW_CGNAME); + printf("Failed to add the cpu controller to the %s cgroup struct\n", LOW_CGNAME); ret = ECGFAIL; goto error; } @@ -402,7 +399,7 @@ static int create_low_priority_cgroup(const struct example_opts * const opts) goto error; } - ctrl = cgroup_add_controller(cg, "memory"); + ctrl = cgroup_add_controller(cgrp, "memory"); if (!ctrl) { printf("Failed to add the memory controller to the %s cgroup struct\n", LOW_CGNAME); @@ -417,7 +414,7 @@ static int create_low_priority_cgroup(const struct example_opts * const opts) goto error; } - ret = cgroup_create_cgroup(cg, 0); + ret = cgroup_create_cgroup(cgrp, 0); if (ret) { printf("Failed to write the %s cgroup to /sys/fs/cgroup: %d: %s\n", LOW_CGNAME, ret, cgroup_strerror(ret)); @@ -425,13 +422,13 @@ static int create_low_priority_cgroup(const struct example_opts * const opts) } error: - if (cg) - cgroup_free(&cg); + if (cgrp) + cgroup_free(&cgrp); return ret; } -static int create_process(pid_t * const pid, const char * const cgname) +static int create_process(pid_t * const pid, const char * const cgrp_name) { int ret = 0; @@ -444,7 +441,7 @@ static int create_process(pid_t * const pid, const char * const cgname) /* * This is the child process. Move it to the requested cgroup */ - ret = cgroup_change_cgroup_path(cgname, getpid(), NULL); + ret = cgroup_change_cgroup_path(cgrp_name, getpid(), NULL); if (ret) exit(0); @@ -461,7 +458,7 @@ error: static int delete_tmp_cgroup(void) { - struct cgroup *cg = NULL; + struct cgroup *cgrp = NULL; int ret, pid_cnt, i; int saved_errno = 0; pid_t *pids = NULL; @@ -484,13 +481,13 @@ static int delete_tmp_cgroup(void) } } - cg = cgroup_new_cgroup(TMP_CGNAME); - if (!cg) { + cgrp = cgroup_new_cgroup(TMP_CGNAME); + if (!cgrp) { printf("Failed to allocate the cgroup struct. Are we out of memory?\n"); goto error; } - ret = cgroup_delete_cgroup(cg, 1); + ret = cgroup_delete_cgroup(cgrp, 1); if (ret) printf("Failed to delete the %s cgroup: %d: %s\n", TMP_CGNAME, ret, cgroup_strerror(ret)); @@ -499,8 +496,8 @@ error: if (pids) free(pids); - if (cg) - cgroup_free(&cg); + if (cgrp) + cgroup_free(&cgrp); if (ret == 0 && saved_errno) ret = ECGFAIL; diff --git a/samples/c/empty_cgroup_v2.c b/samples/c/empty_cgroup_v2.c index a6dcf688..0d9312a4 100644 --- a/samples/c/empty_cgroup_v2.c +++ b/samples/c/empty_cgroup_v2.c @@ -15,7 +15,7 @@ int main(int argc, char **argv) { - struct cgroup *cgroup = NULL; + struct cgroup *cgrp = NULL; int ret = 0; ret = cgroup_init(); @@ -24,17 +24,17 @@ int main(int argc, char **argv) exit(1); } - cgroup = cgroup_new_cgroup(CGRP_NAME); - if (!cgroup) { + cgrp = cgroup_new_cgroup(CGRP_NAME); + if (!cgrp) { fprintf(stderr, "Failed to allocate cgroup %s\n", CGRP_NAME); exit(1); } - ret = cgroup_create_cgroup(cgroup, 0); + ret = cgroup_create_cgroup(cgrp, 0); if (ret) fprintf(stderr, "Failed to create cgroup %s\n", CGRP_NAME); - cgroup_free(&cgroup); + cgroup_free(&cgrp); return ret; } diff --git a/samples/c/get_variable_names.c b/samples/c/get_variable_names.c index da4e5d12..de121aa3 100644 --- a/samples/c/get_variable_names.c +++ b/samples/c/get_variable_names.c @@ -8,9 +8,9 @@ int main(int argc, char *argv[]) { - struct cgroup_controller *group_controller = NULL; - struct cgroup *group = NULL; - char group_name[] = "/"; + struct cgroup_controller *cgrp_controller = NULL; + struct cgroup *cgrp = NULL; + char cgrp_name[] = "/"; char *name; int count; int ret; @@ -27,31 +27,31 @@ int main(int argc, char *argv[]) exit(1); } - group = cgroup_new_cgroup(group_name); - if (group == NULL) { - printf("cannot create group '%s'\n", group_name); + cgrp = cgroup_new_cgroup(cgrp_name); + if (cgrp == NULL) { + printf("cannot create cgrp '%s'\n", cgrp_name); return -1; } - ret = cgroup_get_cgroup(group); + ret = cgroup_get_cgroup(cgrp); if (ret != 0) { printf("cannot read group '%s': %s\n", - group_name, cgroup_strerror(ret)); + cgrp_name, cgroup_strerror(ret)); } for (i = 1; i < argc; i++) { - group_controller = cgroup_get_controller(group, argv[i]); - if (group_controller == NULL) { + cgrp_controller = cgroup_get_controller(cgrp, argv[i]); + if (cgrp_controller == NULL) { printf("cannot find controller '%s' in group '%s'\n", - argv[i], group_name); + argv[i], cgrp_name); ret = -1; continue; } - count = cgroup_get_value_name_count(group_controller); + count = cgroup_get_value_name_count(cgrp_controller); for (j = 0; j < count; j++) { - name = cgroup_get_value_name(group_controller, j); + name = cgroup_get_value_name(cgrp_controller, j); if (name != NULL) printf("%s\n", name); } diff --git a/samples/c/read_stats.c b/samples/c/read_stats.c index 92974d1e..5f8f5be7 100644 --- a/samples/c/read_stats.c +++ b/samples/c/read_stats.c @@ -23,10 +23,8 @@ int read_stats(char *path, char *controller) printf("Stats for %s:\n", path); printf("%s: %s", stat.name, stat.value); - while ((ret = cgroup_read_stats_next(&handle, &stat)) != - ECGEOF) { + while ((ret = cgroup_read_stats_next(&handle, &stat)) != ECGEOF) printf("%s: %s", stat.name, stat.value); - } cgroup_read_stats_end(&handle); printf("\n"); @@ -36,7 +34,7 @@ int read_stats(char *path, char *controller) int main(int argc, char *argv[]) { struct cgroup_file_info info; - char cgroup_path[FILENAME_MAX]; + char cgrp_path[FILENAME_MAX]; char *controller; int root_len; void *handle; @@ -44,8 +42,7 @@ int main(int argc, char *argv[]) int ret; if (argc < 2) { - fprintf(stderr, "Usage %s: \n", - argv[0]); + fprintf(stderr, "Usage %s: \n", argv[0]); exit(EXIT_FAILURE); } @@ -65,8 +62,8 @@ int main(int argc, char *argv[]) } root_len = strlen(info.full_path) - 1; - strncpy(cgroup_path, info.path, FILENAME_MAX - 1); - ret = read_stats(cgroup_path, controller); + strncpy(cgrp_path, info.path, FILENAME_MAX - 1); + ret = read_stats(cgrp_path, controller); if (ret < 0) exit(EXIT_FAILURE); @@ -74,9 +71,9 @@ int main(int argc, char *argv[]) ECGEOF) { if (info.type != CGROUP_FILE_TYPE_DIR) continue; - strncpy(cgroup_path, info.full_path + root_len, FILENAME_MAX - 1); - strcat(cgroup_path, "/"); - ret = read_stats(cgroup_path, controller); + strncpy(cgrp_path, info.full_path + root_len, FILENAME_MAX - 1); + strcat(cgrp_path, "/"); + ret = read_stats(cgrp_path, controller); if (ret < 0) exit(EXIT_FAILURE); } diff --git a/samples/c/test_functions.c b/samples/c/test_functions.c index 025f2ffd..8a829a4c 100644 --- a/samples/c/test_functions.c +++ b/samples/c/test_functions.c @@ -53,13 +53,13 @@ void test_cgroup_init(int retcode, int i) * Tests the cgroup_attach_cgroup() api under different scenarios * @param retcode error code in case any error is expected from api * @param cgrp the group to assign the task to - * @param group1 the name of the group under first (single) mountpoint - * @param group2 the name of the group under 2nd moutpoint for multimount + * @param cgrp1 the name of the group under first (single) mountpoint + * @param cgrp2 the name of the group under 2nd moutpoint for multimount * @param i the test number * @param k the message enum number to print the useful message */ void test_cgroup_attach_task(int retcode, struct cgroup *cgrp, - const char *group1, const char *group2, pid_t pid, + const char *cgrp1, const char *cgrp2, pid_t pid, int k, int i) { char tasksfile[FILENAME_MAX], tasksfile2[FILENAME_MAX]; @@ -88,13 +88,13 @@ void test_cgroup_attach_task(int retcode, struct cgroup *cgrp, /* API returned success, so perform check */ if (retval == 0) { - build_path(tasksfile, mountpoint, group1, "tasks"); + build_path(tasksfile, mountpoint, cgrp1, "tasks"); if (check_task(tasksfile, 0)) { if (fs_mounted == 2) { /* multiple mounts */ build_path(tasksfile2, mountpoint2, - group2, "tasks"); + cgrp2, "tasks"); if (check_task(tasksfile2, 0)) { message(i, PASS, "attach_task()", retval, info[TASKINGRP]); @@ -716,7 +716,7 @@ void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i) char controller_name[FILENAME_MAX], control_file[FILENAME_MAX]; char wr[SIZE], extra[] = "in cgroup_compare_cgroup"; - struct cgroup *cgroup1 = NULL, *cgroup2 = NULL; + struct cgroup *cgrp1 = NULL, *cgrp2 = NULL; struct cgroup_controller *controller = NULL; struct cntl_val_t cval; @@ -733,14 +733,14 @@ void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i) else message(i++, FAIL, "compare_cgroup()", retval, info[NULLGRP]); - cgroup1 = cgroup_new_cgroup("testgroup"); - cgroup2 = cgroup_new_cgroup("testgroup"); - cgroup_set_uid_gid(cgroup1, 0, 0, 0, 0); - cgroup_set_uid_gid(cgroup2, 0, 0, 0, 0); + cgrp1 = cgroup_new_cgroup("testgroup"); + cgrp2 = cgroup_new_cgroup("testgroup"); + cgroup_set_uid_gid(cgrp1, 0, 0, 0, 0); + cgroup_set_uid_gid(cgrp2, 0, 0, 0, 0); retval = set_controller(ctl1, controller_name, control_file); - controller = cgroup_add_controller(cgroup1, controller_name); + controller = cgroup_add_controller(cgrp1, controller_name); if (controller) { retval = add_control_value(controller, control_file, wr, STRING, cval); @@ -748,7 +748,7 @@ void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i) message(i++, FAIL, wr, retval, extra); } - controller = cgroup_add_controller(cgroup2, controller_name); + controller = cgroup_add_controller(cgrp2, controller_name); if (controller) { retval = add_control_value(controller, control_file, wr, STRING, cval); @@ -756,7 +756,7 @@ void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i) message(i++, FAIL, wr, retval, extra); } - retval = cgroup_compare_cgroup(cgroup1, cgroup2); + retval = cgroup_compare_cgroup(cgrp1, cgrp2); if (retval) message(i++, FAIL, "compare_cgroup()", retval, info[NOMESSAGE]); else @@ -764,7 +764,7 @@ void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i) /* Test the api by putting diff number of controllers in cgroups */ retval = set_controller(ctl2, controller_name, control_file); - controller = cgroup_add_controller(cgroup2, controller_name); + controller = cgroup_add_controller(cgrp2, controller_name); if (controller) { retval = add_control_value(controller, control_file, wr, STRING, cval); @@ -772,14 +772,14 @@ void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i) message(i++, FAIL, wr, retval, extra); } - retval = cgroup_compare_cgroup(cgroup1, cgroup2); + retval = cgroup_compare_cgroup(cgrp1, cgrp2); if (retval == ECGROUPNOTEQUAL) message(i++, PASS, "compare_cgroup()", retval, info[NOMESSAGE]); else message(i++, FAIL, "compare_cgroup()", retval, info[NOMESSAGE]); - cgroup_free(&cgroup1); - cgroup_free(&cgroup2); + cgroup_free(&cgrp1); + cgroup_free(&cgrp2); } /** @@ -825,10 +825,10 @@ void test_cgroup_get_cgroup(int ctl1, int ctl2, struct uid_gid_t ids, int i) cgroup_free(&cgroup_filled); /* 3. - * Test with name filled cgroup. Ensure the group group1 exists + * Test with name filled cgroup. Ensure the group cgrp1 exists * in the filesystem before calling this test function */ - cgroup_filled = cgroup_new_cgroup("group1"); + cgroup_filled = cgroup_new_cgroup("cgrp1"); if (!cgroup_filled) message(i++, FAIL, "new_cgroup()", 0, info[NOMESSAGE]); @@ -893,31 +893,31 @@ void test_cgroup_get_cgroup(int ctl1, int ctl2, struct uid_gid_t ids, int i) */ void test_cgroup_add_free_controller(int i) { - struct cgroup *cgroup1 = NULL, *cgroup2 = NULL; + struct cgroup *cgrp1 = NULL, *cgrp2 = NULL; struct cgroup_controller *cgctl1, *cgctl2; /* Test with a Null cgroup */ - cgctl1 = cgroup_add_controller(cgroup1, "cpu"); + cgctl1 = cgroup_add_controller(cgrp1, "cpu"); if (!cgctl1) message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]); else message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]); - cgroup1 = cgroup_new_cgroup("testgroup"); - cgctl1 = cgroup_add_controller(cgroup1, "cpuset"); + cgrp1 = cgroup_new_cgroup("testgroup"); + cgctl1 = cgroup_add_controller(cgrp1, "cpuset"); if (cgctl1) message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]); else message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]); - cgctl2 = cgroup_add_controller(cgroup1, "cpu"); + cgctl2 = cgroup_add_controller(cgrp1, "cpu"); if (cgctl2) message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]); else message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]); - cgroup_free(&cgroup1); - cgroup_free_controllers(cgroup2); + cgroup_free(&cgrp1); + cgroup_free_controllers(cgrp2); } /** diff --git a/samples/c/test_named_hierarchy.c b/samples/c/test_named_hierarchy.c index c0bf7eeb..22e1ead1 100644 --- a/samples/c/test_named_hierarchy.c +++ b/samples/c/test_named_hierarchy.c @@ -12,32 +12,30 @@ int main(void) { struct cgroup_controller *cgc; - struct cgroup *cgroup; + struct cgroup *cgrp; int ret; ret = cgroup_init(); if (ret) { - printf("FAIL: cgroup_init failed with %s\n", - cgroup_strerror(ret)); + printf("FAIL: cgroup_init failed with %s\n", cgroup_strerror(ret)); exit(3); } - cgroup = cgroup_new_cgroup("test"); - if (!cgroup) { + cgrp = cgroup_new_cgroup("test"); + if (!cgrp) { printf("FAIL: cgroup_new_cgroup failed\n"); exit(3); } - cgc = cgroup_add_controller(cgroup, "name=test"); + cgc = cgroup_add_controller(cgrp, "name=test"); if (!cgc) { printf("FAIL: cgroup_add_controller failed\n"); exit(3); } - ret = cgroup_create_cgroup(cgroup, 1); + ret = cgroup_create_cgroup(cgrp, 1); if (ret) { - printf("FAIL: cgroup_create_cgroup failed with %s\n", - cgroup_strerror(ret)); + printf("FAIL: cgroup_create_cgroup failed with %s\n", cgroup_strerror(ret)); exit(3); } diff --git a/samples/c/walk_task.c b/samples/c/walk_task.c index 1a9f59d8..20288cd2 100644 --- a/samples/c/walk_task.c +++ b/samples/c/walk_task.c @@ -8,12 +8,12 @@ int main(int argc, char *argv[]) { - char *group = NULL; + char *cgrp = NULL; void *handle; int ret, i; if (argc < 2) { - printf("No list of groups provided\n"); + printf("No list of cgroups provided\n"); return -1; } @@ -26,10 +26,10 @@ int main(int argc, char *argv[]) for (i = 1; i < argc; i++) { pid_t pid; - group = strdup(argv[i]); - printf("Printing the details of groups %s\n", group); + cgrp = strdup(argv[i]); + printf("Printing the details of cgroups %s\n", cgrp); - ret = cgroup_get_task_begin(group, "cpu", &handle, &pid); + ret = cgroup_get_task_begin(cgrp, "cpu", &handle, &pid); while (!ret) { printf("Pid is %u\n", pid); ret = cgroup_get_task_next(&handle, &pid); @@ -37,13 +37,12 @@ int main(int argc, char *argv[]) printf("cgroup_get_task_next failed with %s\n", cgroup_strerror(ret)); if (ret == ECGOTHER) - printf("failure with %s\n", - strerror(errno)); + printf("failure with %s\n", strerror(errno)); return -1; } } - free(group); - group = NULL; + free(cgrp); + cgrp = NULL; ret = cgroup_get_task_end(&handle); } diff --git a/samples/c/wrapper_test.c b/samples/c/wrapper_test.c index c1f88371..6929c9cf 100644 --- a/samples/c/wrapper_test.c +++ b/samples/c/wrapper_test.c @@ -7,33 +7,33 @@ int main(void) { - struct cgroup *cgroup; struct cgroup_controller *cgc; + struct cgroup *cgrp; int fail = 0; - cgroup = cgroup_new_cgroup("test"); - cgc = cgroup_add_controller(cgroup, "cpu"); + cgrp = cgroup_new_cgroup("test"); + cgc = cgroup_add_controller(cgrp, "cpu"); cgroup_add_value_int64(cgc, "cpu.shares", 2048); cgroup_add_value_uint64(cgc, "cpu.something", 1000); cgroup_add_value_bool(cgc, "cpu.bool", 1); - if (!strcmp(cgroup->controller[0]->values[0]->name, "cpu.shares")) { - if (strcmp(cgroup->controller[0]->values[0]->value, "2048")) { + if (!strcmp(cgrp->controller[0]->values[0]->name, "cpu.shares")) { + if (strcmp(cgrp->controller[0]->values[0]->value, "2048")) { printf("FAIL for add_value_int\n"); fail = 1; } } - if (!strcmp(cgroup->controller[0]->values[1]->name, "cpu.something")) { - if (strcmp(cgroup->controller[0]->values[1]->value, "1000")) { + if (!strcmp(cgrp->controller[0]->values[1]->name, "cpu.something")) { + if (strcmp(cgrp->controller[0]->values[1]->value, "1000")) { printf("FAIL for add_value_uint\n"); fail = 1; } } - if (!strcmp(cgroup->controller[0]->values[2]->name, "cpu.bool")) { - if (strcmp(cgroup->controller[0]->values[2]->value, "1")) { + if (!strcmp(cgrp->controller[0]->values[2]->name, "cpu.bool")) { + if (strcmp(cgrp->controller[0]->values[2]->value, "1")) { printf("FAIL for add_value_bool\n"); fail = 1; }