]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
samples/get_variable_names.c:fix checkpatch.pl warnings
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 16 Mar 2022 16:04:00 +0000 (21:34 +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, 2 warnings, 59 lines checked

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

index f8a0043662362664e98903ba74c4141e056bef7d..da4e5d1223505c48552bdf62d693e9939a58a123 100644 (file)
@@ -1,19 +1,20 @@
 // SPDX-License-Identifier: LGPL-2.1-only
+#include "../src/libcgroup-internal.h"
 #include <libcgroup.h>
-#include <stdio.h>
+
 #include <stdlib.h>
 #include <string.h>
-#include "../src/libcgroup-internal.h"
+#include <stdio.h>
 
 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);
                }
        }