From dd78ba4648cdb0e3e411f6a2bf20a21e222ca658 Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Wed, 16 Mar 2022 21:43:15 +0530 Subject: [PATCH] samples/walk_test.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, 0 warnings, 121 lines checked Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- samples/c/walk_test.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/samples/c/walk_test.c b/samples/c/walk_test.c index 5345223f..20c7641b 100644 --- a/samples/c/walk_test.c +++ b/samples/c/walk_test.c @@ -1,29 +1,31 @@ // SPDX-License-Identifier: LGPL-2.1-only -#include +#include + #include -#include #include #include -#include +#include + +#include 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: \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; } -- 2.47.2