Skip to content

Commit e8f2db7

Browse files
committed
py/runtime: Zero out fs_user_mount array in mp_init.
There's no need to force ports to copy-and-paste this initialisation code. If FSUSERMOUNT is enabled then this zeroing out must be done.
1 parent e83f140 commit e8f2db7

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

esp8266/main.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ STATIC void mp_reset(void) {
5252
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_lib));
5353
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_));
5454
mp_obj_list_init(mp_sys_argv, 0);
55-
#if MICROPY_VFS_FAT
56-
memset(MP_STATE_PORT(fs_user_mount), 0, sizeof(MP_STATE_PORT(fs_user_mount)));
57-
#endif
5855
MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
5956
MP_STATE_PORT(term_obj) = MP_OBJ_NULL;
6057
MP_STATE_PORT(dupterm_arr_obj) = MP_OBJ_NULL;

py/runtime.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ void mp_init(void) {
9191
MP_STATE_VM(mp_module_builtins_override_dict) = NULL;
9292
#endif
9393

94+
#if MICROPY_FSUSERMOUNT
95+
// zero out the pointers to the user-mounted devices
96+
memset(MP_STATE_VM(fs_user_mount), 0, sizeof(MP_STATE_VM(fs_user_mount)));
97+
#endif
98+
9499
#if MICROPY_PY_THREAD_GIL
95100
mp_thread_mutex_init(&MP_STATE_VM(gil_mutex));
96101
#endif

stmhal/main.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,6 @@ int main(void) {
439439
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash_slash_lib));
440440
mp_obj_list_init(mp_sys_argv, 0);
441441

442-
// zero out the pointers to the mounted devices
443-
memset(MP_STATE_PORT(fs_user_mount), 0, sizeof(MP_STATE_PORT(fs_user_mount)));
444-
445442
// Initialise low-level sub-systems. Here we need to very basic things like
446443
// zeroing out memory and resetting any of the sub-systems. Following this
447444
// we can run Python scripts (eg boot.py), but anything that is configurable

0 commit comments

Comments
 (0)