diff options
author | Sean Burton <Sean.Burton@thalesesecurity.com> | 2018-12-13 12:10:35 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-01-27 11:08:25 +1100 |
commit | e33bc59712aa484107dc1cd4009dd8ab2da6dcb2 (patch) | |
tree | 5f15864a4926e76e8a4882f14d18b4835052d4bf /py/persistentcode.c | |
parent | 35687a87ec3fc28654933d7d37bfb82cb04f5227 (diff) | |
download | micropython-e33bc59712aa484107dc1cd4009dd8ab2da6dcb2.tar.gz micropython-e33bc59712aa484107dc1cd4009dd8ab2da6dcb2.zip |
py: Remove calls to file reader functions when these are disabled.
If MICROPY_PERSISTENT_CODE_LOAD or MICROPY_ENABLE_COMPILER are enabled then
code gets enabled that calls file reading functions which may be disabled
if no readers have been implemented.
To fix this, introduce a MICROPY_HAS_FILE_READER variable, which is
automatically set if MICROPY_READER_POSIX or MICROPY_READER_VFS is set but
can also be manually set if a custom reader is being implemented. Then
disable the file reading calls if this is not set.
Diffstat (limited to 'py/persistentcode.c')
-rw-r--r-- | py/persistentcode.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/py/persistentcode.c b/py/persistentcode.c index 7113b0dc2e..88e958d8ff 100644 --- a/py/persistentcode.c +++ b/py/persistentcode.c @@ -232,12 +232,16 @@ mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len) { return mp_raw_code_load(&reader); } +#if MICROPY_HAS_FILE_READER + mp_raw_code_t *mp_raw_code_load_file(const char *filename) { mp_reader_t reader; mp_reader_new_file(&reader, filename); return mp_raw_code_load(&reader); } +#endif // MICROPY_HAS_FILE_READER + #endif // MICROPY_PERSISTENT_CODE_LOAD #if MICROPY_PERSISTENT_CODE_SAVE |