From 28d2272e72c8168e4bc4c6232bef8325f8a6722d Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Wed, 16 Mar 2022 21:42:57 +0530 Subject: [PATCH] samples/walk_task.c: fix checkpatch.pl warnings Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl, except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local variable declarations and header file reordering. In summary, this patch fixes the following checkpatch.pl recommendations: total: 0 errors, 1 warnings, 49 lines checked Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- samples/c/walk_task.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/samples/c/walk_task.c b/samples/c/walk_task.c index 5ddc3609..1a9f59d8 100644 --- a/samples/c/walk_task.c +++ b/samples/c/walk_task.c @@ -1,15 +1,16 @@ // SPDX-License-Identifier: LGPL-2.1-only -#include #include + #include #include #include +#include int main(int argc, char *argv[]) { - int ret, i; char *group = NULL; void *handle; + int ret, i; if (argc < 2) { printf("No list of groups provided\n"); @@ -17,7 +18,6 @@ int main(int argc, char *argv[]) } ret = cgroup_init(); - if (ret) { printf("cgroup_init failed with %s\n", cgroup_strerror(ret)); return -1; @@ -25,18 +25,20 @@ 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); + ret = cgroup_get_task_begin(group, "cpu", &handle, &pid); while (!ret) { printf("Pid is %u\n", pid); ret = cgroup_get_task_next(&handle, &pid); if (ret && ret != ECGEOF) { printf("cgroup_get_task_next failed with %s\n", - cgroup_strerror(ret)); + cgroup_strerror(ret)); if (ret == ECGOTHER) printf("failure with %s\n", - strerror(errno)); + strerror(errno)); return -1; } } @@ -46,5 +48,4 @@ int main(int argc, char *argv[]) } return 0; - } -- 2.47.2