aboutsummaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorDamien George2020-01-09 11:01:14 +1100
committerDamien George2020-01-09 11:25:26 +1100
commitbfbd94401d9cf658fc50b2e45896aba300a7af71 (patch)
tree21aec2207f432658083a26ed5172f9ce0e57ee43 /ports
parente3187b052f14872fdb5e2d2338d359013a544fae (diff)
py: Make mp_obj_get_type() return a const ptr to mp_obj_type_t.
Most types are in rodata/ROM, and mp_obj_base_t.type is a constant pointer, so enforce this const-ness throughout the code base. If a type ever needs to be modified (eg a user type) then a simple cast can be used.
Diffstat (limited to 'ports')
-rw-r--r--ports/stm32/moduos.c2
-rw-r--r--ports/stm32/usb.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/ports/stm32/moduos.c b/ports/stm32/moduos.c
index 8bf58623c..cafe2fe32 100644
--- a/ports/stm32/moduos.c
+++ b/ports/stm32/moduos.c
@@ -111,7 +111,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_urandom_obj, os_urandom);
#endif
bool mp_uos_dupterm_is_builtin_stream(mp_const_obj_t stream) {
- mp_obj_type_t *type = mp_obj_get_type(stream);
+ const mp_obj_type_t *type = mp_obj_get_type(stream);
return type == &pyb_uart_type
#if MICROPY_HW_ENABLE_USB
|| type == &pyb_usb_vcp_type
diff --git a/ports/stm32/usb.c b/ports/stm32/usb.c
index 8a4b7485b..432d55a31 100644
--- a/ports/stm32/usb.c
+++ b/ports/stm32/usb.c
@@ -533,7 +533,7 @@ STATIC mp_obj_t pyb_usb_mode(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
mp_raise_ValueError("too many logical units");
}
for (size_t i = 0; i < msc_n; ++i) {
- mp_obj_type_t *type = mp_obj_get_type(items[i]);
+ const mp_obj_type_t *type = mp_obj_get_type(items[i]);
if (type == &pyb_flash_type
#if MICROPY_HW_ENABLE_SDCARD
|| type == &pyb_sdcard_type