]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mountpoint: simplify if statement
authorSami Kerola <kerolasa@iki.fi>
Wed, 3 Sep 2014 19:46:29 +0000 (20:46 +0100)
committerSami Kerola <kerolasa@iki.fi>
Fri, 19 Sep 2014 18:31:01 +0000 (19:31 +0100)
Returning straight after print_devno() makes the code to be more obvious
and removes need for long else statement.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/mountpoint.c

index 4161d206f54e27660a1a9eb55cdfc360e18f9d80..0aaa290fea5e8c9f154bb2f31b1c588c4bd1a0ca 100644 (file)
@@ -132,7 +132,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
 
 int main(int argc, char **argv)
 {
-       int c, rc = 0;
+       int c;
        struct mountpoint_control ctl = { 0 };
 
        static const struct option longopts[] = {
@@ -186,18 +186,15 @@ int main(int argc, char **argv)
                return EXIT_FAILURE;
        }
        if (ctl.dev_devno)
-               rc = print_devno(&ctl);
-       else {
-               if (dir_to_device(&ctl)) {
-                       if (!ctl.quiet)
-                               printf(_("%s is not a mountpoint\n"), ctl.path);
-                       return EXIT_FAILURE;
-               }
-               if (ctl.fs_devno)
-                       printf("%u:%u\n", major(ctl.dev), minor(ctl.dev));
-               else if (!ctl.quiet)
-                       printf(_("%s is a mountpoint\n"), ctl.path);
+               return print_devno(&ctl) ? EXIT_FAILURE : EXIT_SUCCESS;
+       if (dir_to_device(&ctl)) {
+               if (!ctl.quiet)
+                       printf(_("%s is not a mountpoint\n"), ctl.path);
+               return EXIT_FAILURE;
        }
-
-       return rc ? EXIT_FAILURE : EXIT_SUCCESS;
+       if (ctl.fs_devno)
+               printf("%u:%u\n", major(ctl.dev), minor(ctl.dev));
+       else if (!ctl.quiet)
+               printf(_("%s is a mountpoint\n"), ctl.path);
+       return EXIT_SUCCESS;
 }