summaryrefslogtreecommitdiff
path: root/py/obj.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-03-23 16:17:40 +1100
committerDamien George <damien.p.george@gmail.com>2017-03-23 16:17:40 +1100
commitc88cfe165b0ab39c5d9392fb02dd12f22be1a28d (patch)
treedf03d503b13f11fde8730956f4adf883ce153496 /py/obj.c
parent3f3df435014cc835ce9357e15ddb8996c5866f43 (diff)
py: Use size_t as len argument and return type of mp_get_index.
These values are used to compute memory addresses and so size_t is the more appropriate type to use.
Diffstat (limited to 'py/obj.c')
-rw-r--r--py/obj.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/py/obj.c b/py/obj.c
index 4534ef1b2..65a35c86f 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -351,7 +351,7 @@ void mp_obj_get_array_fixed_n(mp_obj_t o, mp_uint_t len, mp_obj_t **items) {
}
// is_slice determines whether the index is a slice index
-mp_uint_t mp_get_index(const mp_obj_type_t *type, mp_uint_t len, mp_obj_t index, bool is_slice) {
+size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool is_slice) {
mp_int_t i;
if (MP_OBJ_IS_SMALL_INT(index)) {
i = MP_OBJ_SMALL_INT_VALUE(index);
@@ -384,7 +384,9 @@ mp_uint_t mp_get_index(const mp_obj_type_t *type, mp_uint_t len, mp_obj_t index,
}
}
}
- return i;
+
+ // By this point 0 <= i <= len and so fits in a size_t
+ return (size_t)i;
}
mp_obj_t mp_obj_id(mp_obj_t o_in) {