diff mbox series

[LEDE-DEV,mountd] mount: change mount_dev_del() argument to struct mount *

Message ID 20180209152149.8850-1-zajec5@gmail.com
State Accepted
Delegated to: Rafał Miłecki
Headers show
Series [LEDE-DEV,mountd] mount: change mount_dev_del() argument to struct mount * | expand

Commit Message

Rafał Miłecki Feb. 9, 2018, 3:21 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

Caller of mount_dev_del() already has struct mount * so there is no
point in passing matchin device and then looking for struct mount *
again.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 mount.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/mount.c b/mount.c
index f995745..646cc30 100644
--- a/mount.c
+++ b/mount.c
@@ -567,23 +567,19 @@  static void mount_dev_add(char *dev)
 	}
 }
 
-static void mount_dev_del(char *dev)
+static void mount_dev_del(struct mount *mount)
 {
-	struct mount *mount = mount_find(0, dev);
 	char tmp[256];
-	if(mount)
-	{
-		if(mount->mounted)
-		{
-			snprintf(tmp, 256, "%s%s", "/tmp/run/mountd/", mount->name);
-			log_printf("%s has dissappeared ... unmounting\n", tmp);
-			snprintf(tmp, 256, "%s%s", "/tmp/run/mountd/", mount->dev);
-			system_printf("/bin/umount %s", tmp);
-			rmdir(tmp);
-			snprintf(tmp, 64, "%s%s", uci_path, mount->name);
-			unlink(tmp);
-			mount_dump_uci_state();
-		}
+
+	if (mount->mounted) {
+		snprintf(tmp, 256, "%s%s", "/tmp/run/mountd/", mount->name);
+		log_printf("%s has dissappeared ... unmounting\n", tmp);
+		snprintf(tmp, 256, "%s%s", "/tmp/run/mountd/", mount->dev);
+		system_printf("/bin/umount %s", tmp);
+		rmdir(tmp);
+		snprintf(tmp, 64, "%s%s", uci_path, mount->name);
+		unlink(tmp);
+		mount_dump_uci_state();
 	}
 }
 
@@ -748,7 +744,7 @@  static void mount_enum_drives(void)
 		}
 		if(!check_block(q->dev)||del)
 		{
-			mount_dev_del(q->dev);
+			mount_dev_del(q);
 			p->prev->next = p->next;
 			p->next->prev = p->prev;
 			p = p->next;