From: Kamalesh Babulal Date: Wed, 16 Mar 2022 16:04:00 +0000 (+0530) Subject: samples/get_variable_names.c:fix checkpatch.pl warnings X-Git-Tag: v3.0~152 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ee1545f0338043e90113f918970f4bcd09fd2b0;p=thirdparty%2Flibcgroup.git samples/get_variable_names.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, 2 warnings, 59 lines checked Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/samples/c/get_variable_names.c b/samples/c/get_variable_names.c index f8a00436..da4e5d12 100644 --- a/samples/c/get_variable_names.c +++ b/samples/c/get_variable_names.c @@ -1,19 +1,20 @@ // SPDX-License-Identifier: LGPL-2.1-only +#include "../src/libcgroup-internal.h" #include -#include + #include #include -#include "../src/libcgroup-internal.h" +#include int main(int argc, char *argv[]) { - int ret; - int i, j; - int count; - char *name; struct cgroup_controller *group_controller = NULL; struct cgroup *group = NULL; char group_name[] = "/"; + char *name; + int count; + int ret; + int i, j; if (argc < 2) { printf("no list of groups provided\n"); @@ -21,7 +22,6 @@ int main(int argc, char *argv[]) } ret = cgroup_init(); - if (ret) { printf("cgroup_init failed with %s\n", cgroup_strerror(ret)); exit(1); @@ -43,16 +43,17 @@ int main(int argc, char *argv[]) group_controller = cgroup_get_controller(group, argv[i]); if (group_controller == NULL) { - printf("cannot find controller "\ - "'%s' in group '%s'\n", argv[i], group_name); + printf("cannot find controller '%s' in group '%s'\n", + argv[i], group_name); ret = -1; continue; } + count = cgroup_get_value_name_count(group_controller); for (j = 0; j < count; j++) { name = cgroup_get_value_name(group_controller, j); if (name != NULL) - printf("%s \n", name); + printf("%s\n", name); } }