Skip to content

Commit 238ab50

Browse files
swegenerdpgeorge
authored andcommitted
py: Deactivate more code without MICROPY_PY_SYS
When compiler optimization has been turned on, gcc knows that this code block is not going to be executed. But with -O0 it complains about path_items being used uninitialized. Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
1 parent 98d8d59 commit 238ab50

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

py/builtinimport.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ STATIC mp_import_stat_t stat_dir_or_file(vstr_t *path) {
7777
}
7878

7979
STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) {
80+
#if MICROPY_PY_SYS
8081
// extract the list of paths
81-
mp_uint_t path_num = 0;
82+
mp_uint_t path_num;
8283
mp_obj_t *path_items;
83-
#if MICROPY_PY_SYS
8484
mp_obj_list_get(mp_sys_path, &path_num, &path_items);
85-
#endif
8685

8786
if (path_num == 0) {
87+
#endif
8888
// mp_sys_path is empty, so just use the given file name
8989
vstr_add_strn(dest, file_str, file_len);
9090
return stat_dir_or_file(dest);
91+
#if MICROPY_PY_SYS
9192
} else {
9293
// go through each path looking for a directory or file
9394
for (mp_uint_t i = 0; i < path_num; i++) {
@@ -108,6 +109,7 @@ STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *d
108109
// could not find a directory or file
109110
return MP_IMPORT_STAT_NO_EXIST;
110111
}
112+
#endif
111113
}
112114

113115
STATIC void do_load(mp_obj_t module_obj, vstr_t *file) {

0 commit comments

Comments
 (0)