]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
samples/read_stats.c: fix checkpatch.pl warnings
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 16 Mar 2022 16:07:14 +0000 (21:37 +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, 84 lines checked

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

index 34eef4f9d0be4204830100d447127db59e711707..92974d1e3d66799317129b684df2277ee7104fde 100644 (file)
@@ -1,19 +1,20 @@
 // 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>
 
 int read_stats(char *path, char *controller)
 {
-       int ret;
-       void *handle;
        struct cgroup_stat stat;
+       void *handle;
+       int ret;
 
        ret = cgroup_read_stats_begin(controller, path,  &handle, &stat);
-
        if (ret != 0) {
                fprintf(stderr, "stats read failed\n");
                return -1;
@@ -34,13 +35,13 @@ int read_stats(char *path, char *controller)
 
 int main(int argc, char *argv[])
 {
-       int ret;
-       char *controller;
-       void *handle;
        struct cgroup_file_info info;
-       int lvl;
        char cgroup_path[FILENAME_MAX];
+       char *controller;
        int root_len;
+       void *handle;
+       int lvl;
+       int ret;
 
        if (argc < 2) {
                fprintf(stderr, "Usage %s: <controller name>\n",