Skip to content

Commit 968763a

Browse files
committed
factor out storage_object_from_path
1 parent 1eba580 commit 968763a

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

shared-module/storage/__init__.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,15 @@ void common_hal_storage_umount_object(mp_obj_t vfs_obj) {
109109
mp_vfs_proxy_call(vfs, MP_QSTR_umount, 0, NULL);
110110
}
111111

112-
void common_hal_storage_umount_path(const char* mount_path) {
113-
// remove vfs from the mount table
114-
mp_obj_t *vfs_obj = NULL;
112+
STATIC mp_obj_t storage_object_from_path(const char* mount_path) {
115113
for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) {
116114
if (strcmp(mount_path, (*vfsp)->str) == 0) {
117-
vfs_obj = (*vfsp)->obj;
118-
break;
115+
return (*vfsp)->obj;
119116
}
120117
}
118+
mp_raise_OSError(MP_EINVAL);
119+
}
121120

122-
if (vfs_obj == NULL) {
123-
mp_raise_OSError(MP_EINVAL);
124-
}
125-
126-
common_hal_storage_umount_object(vfs_obj);
121+
void common_hal_storage_umount_path(const char* mount_path) {
122+
common_hal_storage_umount_object(storage_object_from_path(mount_path));
127123
}

0 commit comments

Comments
 (0)