]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
static-nodes: unify return statements
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 19 Feb 2025 18:35:51 +0000 (19:35 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 21 Feb 2025 19:51:08 +0000 (13:51 -0600)
The write_* functions have different return statement handling. Unify
them by removing "else" if the if-block itself returns and also unify
the error handling by checking for the error case, leaving the success
return statement at the end of the function.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/285
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/static-nodes.c

index f4eeeb69ba60f0c406f56a216d7b9527c74d6bfc..9af30eb83d97e3d3a3644dd26a2074e2238c29f3 100644 (file)
@@ -59,10 +59,10 @@ static int write_human(FILE *out, char modname[], char devname[], char type,
                      "\t\tMajor: %u\n"
                      "\t\tMinor: %u\n",
                      modname, devname, (type == 'c') ? "character" : "block", maj, min);
-       if (ret >= 0)
-               return EXIT_SUCCESS;
-       else
+       if (ret < 0)
                return EXIT_FAILURE;
+
+       return EXIT_SUCCESS;
 }
 
 static const struct static_nodes_format static_nodes_format_human = {
@@ -104,10 +104,10 @@ static int write_devname(FILE *out, char modname[], char devname[], char type,
        int ret;
 
        ret = fprintf(out, "%s %s %c%u:%u\n", modname, devname, type, maj, min);
-       if (ret >= 0)
-               return EXIT_SUCCESS;
-       else
+       if (ret < 0)
                return EXIT_FAILURE;
+
+       return EXIT_SUCCESS;
 }
 
 static const struct static_nodes_format static_nodes_format_devname = {