]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
samples/walk_task.c: fix checkpatch.pl warnings
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 16 Mar 2022 16:12:57 +0000 (21:42 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 16 Mar 2022 21:38:20 +0000 (15:38 -0600)
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 <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
samples/c/walk_task.c

index 5ddc36096ded63a36d75e7a67b34c7f498cc513c..1a9f59d8820a841bd3e8e36b55425f022ddf5e1d 100644 (file)
@@ -1,15 +1,16 @@
 // SPDX-License-Identifier: LGPL-2.1-only
-#include <stdio.h>
 #include <libcgroup.h>
+
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <stdio.h>
 
 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;
-
 }