Fix reference to ffs_strerror when image I/O is disabled.

This commit is contained in:
iabdalkader 2020-12-30 00:32:22 +02:00
parent eb2ba24869
commit ba80759f61
2 changed files with 9 additions and 1 deletions

View File

@ -285,7 +285,7 @@ int imlib_load_cascade(cascade_t *cascade, const char *path)
// xml cascade // xml cascade
return imlib_load_cascade_from_file(cascade, path); return imlib_load_cascade_from_file(cascade, path);
#else #else
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Image I/O is not supported")); return -1;
#endif #endif
} }

View File

@ -35,7 +35,9 @@
static const mp_obj_type_t py_cascade_type; static const mp_obj_type_t py_cascade_type;
static const mp_obj_type_t py_image_type; static const mp_obj_type_t py_image_type;
#if defined(IMLIB_ENABLE_IMAGE_IO)
extern const char *ffs_strerror(FRESULT res); extern const char *ffs_strerror(FRESULT res);
#endif
// Haar Cascade /////////////////////////////////////////////////////////////// // Haar Cascade ///////////////////////////////////////////////////////////////
@ -7231,7 +7233,13 @@ mp_obj_t py_image_load_cascade(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
// Load cascade from file or flash // Load cascade from file or flash
int res = imlib_load_cascade(&cascade, path); int res = imlib_load_cascade(&cascade, path);
if (res != FR_OK) { if (res != FR_OK) {
#if defined(IMLIB_ENABLE_IMAGE_IO)
// cascade is not built-in and failed to load it from file.
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, ffs_strerror(res))); nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, ffs_strerror(res)));
#else
// cascade is not built-in.
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Image I/O is not supported"));
#endif
} }
// Read the number of stages // Read the number of stages