[PATCH 11/17] mountpoint: simplify if statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 sys-utils/mountpoint.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c
index 3392cdd..3155dd4 100644
--- a/sys-utils/mountpoint.c
+++ b/sys-utils/mountpoint.c
@@ -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.devname);
-			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.devname);
+		return print_devno(&ctl) ? EXIT_FAILURE : EXIT_SUCCESS;
+	if (dir_to_device(&ctl)) {
+		if (!ctl.quiet)
+			printf(_("%s is not a mountpoint\n"), ctl.devname);
+		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.devname);
+	return EXIT_SUCCESS;
 }
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux