mount: reorder deleting code in the mount_enum_drives()
authorRafał Miłecki <rafal@milecki.pl>
Fri, 16 Feb 2018 11:50:24 +0000 (12:50 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Wed, 21 Feb 2018 08:34:43 +0000 (09:34 +0100)
Make it execute required unmount code first and then take care of
removing entry from the internal list. This is a small cleanup grouping
code by their purpose.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
mount.c

diff --git a/mount.c b/mount.c
index f2c15a0a16a9d4c99f1bc5a601fe32f4566b5783..b488ede428554cf7aedc39978a16aee540a264a8 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -757,16 +757,18 @@ static void mount_enum_drives(void)
                if(!check_block(q->dev)||del)
                {
                        mount_dev_del(q);
-                       p->prev->next = p->next;
-                       p->next->prev = p->prev;
-                       p = p->next;
                        if (q->status == STATUS_MOUNTED || q->status == STATUS_EXPIRED) {
                                snprintf(tmp, 64, "%s%s", uci_path, q->name);
                                log_printf("unlinking %s\n", tmp);
                                unlink(tmp);
                                system_printf("ACTION=remove DEVICE=%s NAME=%s /sbin/hotplug-call mount", q->dev, q->name);
                        }
+
+                       p->prev->next = p->next;
+                       p->next->prev = p->prev;
+                       p = p->next;
                        free(q);
+
                        mount_dump_uci_state();
                        system_printf("/etc/fonstated/ReloadSamba");
                } else p = p->next;