]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
samples/walk_test.c: fix checkpatch.pl warnings
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 16 Mar 2022 16:13:15 +0000 (21:43 +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, 0 warnings, 121 lines checked

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
samples/c/walk_test.c

index 5345223fcde72921ab8d7f14d7b565185543bf91..20c7641b5ffadfd322fd3322d7c3fa7ec502b41b 100644 (file)
@@ -1,29 +1,31 @@
 // SPDX-License-Identifier: LGPL-2.1-only
-#include <stdio.h>
+#include <libcgroup.h>
+
 #include <stdlib.h>
-#include <sys/types.h>
 #include <unistd.h>
 #include <string.h>
-#include <libcgroup.h>
+#include <stdio.h>
+
+#include <sys/types.h>
 
 void visit_node(struct cgroup_file_info *info, char *root)
 {
        if (info->type == CGROUP_FILE_TYPE_DIR) {
                printf("path %s, parent %s, relative %s, full %s\n",
-                       info->path, info->parent, info->full_path +
-                               + strlen(root) - 1,
-                               info->full_path);
+                       info->path, info->parent,
+                       info->full_path + strlen(root) - 1,
+                       info->full_path);
        }
 }
 
 int main(int argc, char *argv[])
 {
-       int ret;
-       char *controller;
-       void *handle;
        struct cgroup_file_info info;
        char root[FILENAME_MAX];
+       char *controller;
+       void *handle;
        int lvl, i;
+       int ret;
 
        if (argc < 2) {
                fprintf(stderr, "Usage %s: <controller name>\n",
@@ -45,6 +47,7 @@ int main(int argc, char *argv[])
                fprintf(stderr, "Walk failed\n");
                exit(EXIT_FAILURE);
        }
+
        strcpy(root, info.full_path);
        printf("Begin pre-order walk\n");
        printf("root is %s\n", root);
@@ -118,5 +121,6 @@ int main(int argc, char *argv[])
                        break;
        }
        cgroup_walk_tree_end(&handle);
+
        return EXIT_SUCCESS;
 }