diff mbox series

[OpenWrt-Devel,fstools,3/4] block: simplify code picking mount target directory

Message ID 20181130130923.4678-3-zajec5@gmail.com
State Accepted
Delegated to: Rafał Miłecki
Headers show
Series [OpenWrt-Devel,fstools,1/4] block: fix formatting & indent in the mount_device() | expand

Commit Message

Rafał Miłecki Nov. 30, 2018, 1:09 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

Using a set of 3 conditional block each setting "target" variable makes
code easier to follow.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 block.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/block.c b/block.c
index f42d0d6..0671aca 100644
--- a/block.c
+++ b/block.c
@@ -1025,8 +1025,8 @@  static int mount_device(struct probe_info *pr, int type)
 		blockd_notify(device, m, pr);
 
 	if (m) {
-		char *target = m->target;
 		char _target[32];
+		char *target;
 		int err = 0;
 
 		switch (type) {
@@ -1049,8 +1049,9 @@  static int mount_device(struct probe_info *pr, int type)
 		if (m->autofs) {
 			snprintf(_target, sizeof(_target), "/tmp/run/blockd/%s", device);
 			target = _target;
-		}
-		if (!target) {
+		} else if (m->target) {
+			target = m->target;
+		} else {
 			snprintf(_target, sizeof(_target), "/mnt/%s", device);
 			target = _target;
 		}